滑动门技术 - 浏览器兼容性
我正在使用滑动门技术来设计我正在制作的网站上的按钮样式,它似乎可以在 Chrome 中工作,但背景不会为任何其他浏览器显示。 我的按钮代码如下:
<div class="small-white"><a href="#">Done Reading</a></div>
CSS:
.small-white {
float:left;
background:url(images/small-white-sprite.png) right no-repeat;
margin: 15px 5px 0 5px;
padding:0;
display:block;
height:22px;
}
.small-white a {
display:block;
background:url(images/small-white-left.png) no-repeat left;
padding:4px 10px 7px 9px;
color:#333;
text-decoration:none;
float:left;
}
请告知。
提前致谢。 -B
I am using the sliding doors technique to style buttons on a site I'm making and it seems to be working within Chrome but the background is not displaying for any other browser. My code for the button is below:
<div class="small-white"><a href="#">Done Reading</a></div>
CSS:
.small-white {
float:left;
background:url(images/small-white-sprite.png) right no-repeat;
margin: 15px 5px 0 5px;
padding:0;
display:block;
height:22px;
}
.small-white a {
display:block;
background:url(images/small-white-left.png) no-repeat left;
padding:4px 10px 7px 9px;
color:#333;
text-decoration:none;
float:left;
}
Please advise.
Thanks in advance.
-B
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您无论如何都使用两个图像(滑动门通常只涉及一个图像;事实上,这就是重点),因此您可以这样做以保持透明度:
元素应该' t 有
float: left;
(因为它在元素内没有任何东西可以浮动。)
line-height
用于使文本垂直居中。在透明情况下,不可能只使用一张图像,但是如果您知道背景颜色是什么,您可以将图像拼合到该颜色上,然后您将能够只使用一张图像(使用与现在相同的 CSS,但将
small-white-left.png
添加到small-white-sprite.png
的左侧,然后将其用于两个元素。)如果您想要左侧- 按钮的大部分可点击,在
元素中的文本周围放置一个
元素并使用以下 CSS:
Since you're using two images anyways (Sliding Doors usually only involves one image; in fact, that's the point), you can just do this instead to keep transparency:
The
<a>
element shouldn't havefloat: left;
(since it has nothing to float around inside the<li>
element.) Theline-height
is for centering the text vertically.Using just one image isn't possible with transparency, but if you know what the background color will be, you can flatten the image on that color, then you'll be able to use just one image (use the same CSS as now, but add
small-white-left.png
to the left insmall-white-sprite.png
, then use that for both elements.)If you want to have the left-most part of the button clickable, put a
<span>
element around the text in the<a>
element and use this CSS: