我有css sprite图像。它可以正常工作,但问题是我想要锚标签文本的图像右侧,但它显示在左侧.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>标记的文本右侧添加anchorDemo

的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;
}

10-08 08:16
查看更多