HTML如何设置hr的长度,实例在线

HTML如何设置hr的长度

hr元素定义HTML文档中的分割线,默认情况下,hr的长度与父元素宽度的相当,即hr默认的宽度应该是被设置为100%。如果要设置hr的长度,直接设置hr的width属性即可,单位可以是px、cm、em、pt和百分比%等,语法如下:

hr{width:value}

HTML设置hr长度实例代码,及在线编辑器

下方的实例将采用px、cm、em、pt和百分比%五种width属性值来设置hr的长度,代码如下:

<hr id='e1' class='hr'>
<hr id='e2' class='hr'>
<hr id='e3' class='hr'>
<hr id='e4' class='hr'>
<hr id='e5' class='hr'>
<style>
  .hr{border:2px solid skyblue;}
  #e1{width:15pt;}
  #e2{width:35px;}
  #e3{width:5em;}
  #e4{width:10cm;}
  #e5{width:50%;}
</style>

全栈前端 / HTML教程 :


















Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.