Html 如何在html中设置水平线的粗细

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5219317/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:10:22  来源:igfitidea点击:

How can i set thickness of horizontal rule in html

htmlcss

提问by jslearner

How can I set thickness of a horizontal rule in html/CSS

如何在 html/CSS 中设置水平线的粗细

回答by Neil Knight

You could use the SIZEproperty:

您可以使用该SIZE属性:

<hr size="3" />

Please note that this is deprecated. You should really use styles to resolve this.

请注意,这已被弃用。你真的应该使用样式来解决这个问题。

hr {
    height: 3px;
}

回答by LocustHorde

If you have a lot of <hr />in your document, just add a style in your <head>section

如果您<hr />的文档中有很多,只需在您的<head>部分中添加样式

hr
{
    border: 5px solid #000;
}

and change the 5pxto whatever you want.

并将5px更改为您想要的任何值。

editDont use height, it will make your hr look hollow, unless thats what you are looking for.

编辑不要使用高度,它会让你的 hr 看起来空洞,除非那是你要找的。

here is a simple example: http://jsfiddle.net/ErdXg/try out some colors and thickness and play around with it.

这是一个简单的例子:http: //jsfiddle.net/ErdXg/尝试一些颜色和粗细并尝试一下。

回答by Agos

You can use CSS, like this:

您可以使用 CSS,如下所示:

hr {
    height: 20px;
}

回答by BigFatBaby

for other examples of the HR attributes go here

有关 HR 属性的其他示例,请访问此处

回答by Tibe

<hr height="3" style="color:purple;background-color:purple;"></hr>

thats it hehe just change the background color thats it.

就是这样,呵呵,只要改变背景颜色就可以了。

回答by boateng

.cool_line{ 
    display:block;
    border:none;
    color:white;
    height:1px;
    background:lightgray;
    background: -webkit-gradient(radial, 50% 50%, 0, 50% 50%, 350, from(lightgray), to(#fff));
}
Begin

<hr class='cool_line' />

End    

回答by aderchox

Adding the height doesn't work for me anymore as suggested in other answers (at least not working on Chrome 79), instead I've tried this and it works:

正如其他答案中所建议的那样,添加高度对我不再适用(至少不适用于 Chrome 79),相反我已经尝试过这个并且它有效:

.thickhr{
  border:0.1rem solid black;
  height:0;
}