如何使用HTML制作一条垂直线?


当前回答

没有与<hr>元素等值的垂直元素。然而,你可能想尝试的一种方法是在你要分离的东西的左边或右边使用一个简单的边界:

# your_col { Border-left: 1px纯黑色; } < div id = " your_col " > 你的内容在这里 < / div >

其他回答

你可以使用hr(水平线)标签,然后用下面的css旋转90度

hr {   
    transform:rotate(90deg);
    -o-transform:rotate(90deg);
    -moz-transform:rotate(90deg);
    -webkit-transform:rotate(90deg);
}

http://jsfiddle.net/haykaghabekyan/0c969bm6/1/

另一种选择是使用1像素的图像,并设置高度-这个选项将允许您将其浮动到您需要的位置。

但这不是最优雅的解决方案。

您可以通过简单地使用任何html元素的height / width来绘制一条垂直线。

# verticle-line { 宽度:1 px; 最小高度:400 px; 背景:红色; } < div id = " verticle-line " > < / div >

垂直到div

<div style="width:50%"> <div style="border-right:1px solid;"> <ul> <li> Empty div didn't shows line </li> <li> Vertical line length depends on the content in the div </li> <li> Here I am using inline style. You can replace it by external style or internal style. </li> </ul> </div> </div>

到div左边的垂直线

<div style="width:50%"> <div style="border-left:1px solid;"> <ul> <li> Empty div didn't shows line </li> <li> Vertical line length depends on the content in the div </li> <li> Here I am using inline style. You can replace it by external style or internal style. </li> </ul> </div> </div>

在标记周围放置<div>,然后使用CSS来设置它的样式:

.verticalLine { Border-left:厚实实心#ff0000; } < div class = "垂线”> 其他内容 < / div >