gpt4 book ai didi

css - 将 Sprite 图像放在 anchor 标记的右侧?

转载 作者:行者123 更新时间:2023-11-28 09:28:27 25 4
gpt4 key购买 nike

我有 css sprite 图像。它工作正常,但问题是我想要 anchor 标记文本右侧的图像。但它显示在左侧。sprite 图像在这里。

http://jstiles.com/temp/1360875952/ctrls/css-sprite.png

预期结果:

[Mylinktext]<MyImagehere>

我得到的实际结果是

<MyImagehere>[Mylinktext]

我不想在伪类之后使用。因为它也不会在 IE7 浏览器中运行。我的代码如下。

.ctrls
{
font-family:Arial;
font-weight:bold;
font-size:16px;
color:black;
background-image: url(images/ctrlsprite.png);
//background-image: url(images/css-sprite.png);
background-repeat:no-repeat;
text-decoration:none;
display: inline-block;
padding-left:30px;
}
.ctrls:hover
{
background-position: 0px -252px;
text-decoration:underline;
}
a.magenta
{
background-position:0px -144px;
}

和 HTML

<div>
<p>Magenta</p>
<a href="#" class="ctrls magenta">Et Movet</a>
</div>

如何将图片放在文本的右侧?

最佳答案

如何添加 <span>anchor 中文本的右侧标签? Demo

HTML

<div>
<p>Magenta</p> <a href="#" class="ctrls magenta">Et Movet <span class="icon"></span></a>
</div>

CSS

.ctrls {
font-family:Arial;
font-weight:bold;
font-size:16px;
color:black;
text-decoration:none;
}
.ctrls:hover {
text-decoration:underline;
}
.ctrls .icon {
display: inline-block;
background-image: url(http://jstiles.com/temp/1360875952/ctrls/css-sprite.png);
background-repeat:no-repeat;
width: 16px;
height: 16px;
background-position:0px -144px;
}
.ctrls:hover .icon {
background-position: 0px -252px;
}

关于css - 将 Sprite 图像放在 anchor 标记的右侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14884770/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com