gpt4 book ai didi

html - 将 CSS Sprite 背景图像定位到文本右侧

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

我有一个 css sprite,我需要将其作为背景图像放置在某些文本的右侧。就像一个外部链接图标。我还希望文本是全宽的,然后是图像。

我的CSS如下:

.container
{
width:1247px;
background-color:#444;
}

.container a
{
background: transparent url(http://i.imgur.com/s5rf9GY.png) no-repeat;
height: 30px;
width: 30px;
display: block;
}
.container .external
{
background-position: -491px 2px;
}
.container .mail
{
background-position: -526px 0px;
}

fiddle 链接如下:

http://jsfiddle.net/6dw31962/

请帮助。提前致谢

最佳答案

试试这个。

.container {
width:1247px;
/*height:30px;*/
}

.container a {
display: block;
position: relative;
margin-bottom: 15px;
}
.container a:after {
background: transparent url(http://i.imgur.com/s5rf9GY.png) no-repeat;
height: 30px;
width: 30px;
display: inline-flex;
content: '';
position: absolute;
top: -5px;
background-position: -455px 0;
}

.container .external {
background-position: -491px 2px;
}
.container .mail {
background-position: -526px 0px;
}
<div class="container">
<a class="external" href="http://somelink.com/">MyLink</a>
<a class="mail" href="gmail.com">Mail To Us</a>
</div>

关于html - 将 CSS Sprite 背景图像定位到文本右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44300327/

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