我需要提供链接背景样式。由于宽度会有所不同,我需要使用 2 张图片,这就是为什么我的链接中有一个跨度。
我还需要将链接向左浮动,这意味着我必须设置段落以清除两者。
我的解决方案有效,但似乎有很多 css 并添加了额外的 html 元素。有没有更优雅的解决方案?
<p>Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text </p>
<a href="#" class="my-link"><span> This is a link sdafsdafsdaf </span>
</a>
<p>Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text Here is some text </p>
a {
background: url("http://smartpeopletalkfast.co.uk/body-link-bg.jpg") 100% 50%;
line-height: 50px;
float: left;
}
a span {
background: url("http://smartpeopletalkfast.co.uk/body-link-bg-2.jpg") no-repeat;
height: 49px;
display: block;
padding-left: 20px;
padding-right: 40px;
}
p {
clear: both;
}