CSS 样式附加 <hr> 标签?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13466136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
styling additional <hr> tag?
提问by user1676691
I am looking to style an additional <hr>
tag for my side-bar on my website.
我希望<hr>
在我的网站上为我的侧边栏设计一个额外的标签。
How might I be able to do this if I already have an hr defined?
如果我已经定义了一个小时,我怎么能做到这一点?
hr { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 22px 0 21px; height: 0; }
Could I add a style?
我可以添加样式吗?
hr.side { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 22px 0 21px; height: 0; }
so html would be
所以 html 将是
<hr class="side">
?
<hr class="side">
?
回答by Scott Selby
use
用
hr.side { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 22px 0 21px; height: 0; }
then
然后
<hr class="side">
in css the .
refers to a class , and #
to id
在 css 中,.
指的是一个类,和 #
id
EDIT:
编辑:
if you really really wanted to do inline styling with style=""
then it would look like this
如果你真的很想使用内联样式,style=""
那么它看起来像这样
<hr style="border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 22px 0 21px; height: 0;">
This last method is not really the recommended way, but works great if you want to override all css style sheets, and also override any <style> </style>
tags that are embedded in HTML page
最后一种方法并不是真正推荐的方法,但如果您想覆盖所有 css 样式表,并且还覆盖<style> </style>
嵌入在 HTML 页面中的任何标签,则效果很好