如何使用HTML制作垂直线?
<div>
,并使用CSS对其进行样式设计。
.verticalLine {
border-left: thick solid #ff0000;
}
<div class="verticalLine">
some other content
</div>
ul.page_cp > li:not(:first-child) { ...
- papo您可以使用水平线标记来创建垂直线。
<hr width="1" size="500" style="0 auto" />
通过使用最小宽度和大尺寸,水平线变成了垂直线。
<hr width="0" ... />
。 - undefined您可以使用一个空的 <div>
,并将其样式设置为您希望该行出现的样式:
HTML:
<div class="vertical-line"></div>
使用精确高度(覆盖内联样式):
div.vertical-line{
width: 1px; /* Line width */
background-color: black; /* Line color */
height: 100%; /* Override in-line if you want specific height. */
float: left; /* Causes the line to float to left of content.
You can instead use position:absolute or display:inline-block
if this fits better with your design */
}
<div class="vertical-line" style="height: 45px;"></div>
如果您想要3D效果,请为边框设置样式:
div.vertical-line{
width: 0px; /* Use only border style */
height: 100%;
float: left;
border: 1px inset; /* This is default border style for <hr> tag */
}
<div class="vertical-line" style="height: 45px;"></div>
当然,您也可以尝试高级组合:
div.vertical-line{
width: 1px;
background-color: silver;
height: 100%;
float: left;
border: 2px ridge silver ;
border-radius: 2px;
}
<div class="vertical-line" style="height: 45px;"></div>
你也可以使用HTML水平线<hr />
创建垂直线。
html, body{height: 100%;}
hr.vertical {
width: 0px;
height: 100%;
/* or height in PX */
}
<hr class="vertical" />
<hr>
相同。可能还需要额外的样式来浮动在内容的一侧(例如:float:left;
)。 - awe没有垂直等效于<hr>
元素。然而,您可以尝试的一种方法是在您要分隔的内容左侧或右侧使用简单的边框:
#your_col {
border-left: 1px solid black;
}
<div id="your_col">
Your content here
</div>
注册您的元素。
var vr = document.registerElement('v-r'); // vertical rule please, yes!
*所有自定义元素中都必须使用-
。
v-r {
height: 100%;
width: 1px;
border-left: 1px solid gray;
/*display: inline-block;*/
/*margin: 0 auto;*/
}
*您可能需要稍微调整display:inline-block|inline
,因为inline
不会扩展到包含元素的高度。使用边距在容器内居中该行。
js: document.body.appendChild(new vr());
or
HTML: <v-r></v-r>
*很遗憾,您无法创建自定义的自闭标签。
<h1>THIS<v-r></v-r>WORKS</h1>
示例:http://html5.qry.me/vertical-rule
只需将此CSS类应用于您指定的元素即可。
.vr {
height: 100%;
width: 1px;
border-left: 1px solid gray;
/*display: inline-block;*/
/*margin: 0 auto;*/
}
*请查看上面的注释。
display
属性。将其设置为 inline
或 inline-block
中的一个。请参见上面的注释和示例网址。 - Qwerty另一个选择是使用一个1像素的图片,并设置高度 - 这个选项可以让你将其浮动到需要的位置。
虽然这不是最优雅的解决方案。
#verticle-line {
width: 1px;
min-height: 400px;
background: red;
}
<div id="verticle-line"></div>
将 <hr>
旋转90度:
<hr style="width:100px; transform:rotate(90deg);">
在IT技术中有一个用于横线的标签是<hr>
。该标签可以与CSS结合使用,制作横线:
.divider{
margin-left: 5px;
margin-right: 5px;
height: 100px;
width: 1px;
background-color: red;
}
<hr class="divider">
width属性确定了线条的粗细。height属性确定了线条的长度。background-color属性确定了线条的颜色。
<vr>
添加一个规范呢? - OverCoder