如何在两个div之间添加垂直线 [英] how to add vertical line between two divs
本文介绍了如何在两个div之间添加垂直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在两个div
之间建立一条垂直线.据我所知,水平线为hr
,而垂直线为hr
.无论如何,不使用border
就能做到吗?
I want to make a vertical line between two div
s. we have hr
for horizontal line but none for vertical line as I know. Is there anyway to make it without using border
?
<style>
#wrapper_1 {
background-color:pink;
height:100px;
float:left;
width: 100px;
}
#wrapper_2 {
background-color:brown;
height:100px;
width: 100px;
float:right;
}
</style>
<div id="wrapper_1">
Creating slideshows PHP
</div>
<div id="wrapper_2">
Creating slideshows with WordPress
</div>
推荐答案
您还可以使用伪元素创建垂直分隔符.您不需要额外的div即可创建分隔符,只需使用伪元素并根据需要设置其样式即可.
You can also use pseudo elements to make a vertical separator. You don't need an extra div to make a separator just use the pseudo elements and style it according to your needs.
#wrapper_1 {
background-color: pink;
height: 100px;
float: left;
width: 100px;
}
#wrapper_1:after {
content: "";
background-color: #000;
position: absolute;
width: 5px;
height: 100px;
top: 10px;
left: 50%;
display: block;
}
#wrapper_2 {
background-color: brown;
height: 100px;
width: 100px;
float: right;
}
<div id="wrapper_1">
Creating slideshows PHP
</div>
<div id="wrapper_2">
Creating slideshows with WordPress
</div>
PS:当心伪元素的绝对位置. 谢谢.
PS: Beware of the absolute positioning of the pseudo elements. Thanks.
这篇关于如何在两个div之间添加垂直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文