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


当前回答

垂直到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 >

只需使用UTF-8杂项符号之一

The & # 124;

& # x7C;

这就是你所需要的,并且它与所有浏览器兼容。

回头谢谢我。

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

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

你也可以使用HTML符号&#124;呈现为'|'

要添加一条垂直线,你需要样式一个hr。

现在,当你画一条垂直线时,它会出现在页面的中间:

<hr style="width:0.5px;height:500px;"/>

现在把它放在你想要的地方,你可以使用下面的代码:

<hr style="width:0.5px;height:500px;margin-left:-500px;margin-right:500px;"/>

这将把它定位到左边,你可以把它反向定位到右边。