Is this what you were looking for?
#wrapper {
width: 400px;
height: 300px;
border: 1px solid red;
}
#content {
height: 125px;
border: 1px solid blue;
position: relative;
}
#line {
position: absolute;
width:1px;
height: 50px;
bottom: -25px; /*half the height*/
left: 50%;
border-left: 1px solid green;
}
<div id="wrapper">
<div id="content">
<div id="line"></div>
</div>
</div>
The outer container is quite standard.
The inner content div has a relative position, while the line div has an absolute position.
By positioning the line div as a child with the specified positions above, its position is relative to the parent. So when using left: 50%
, it means it's at 50% of the parent element.
An alternative approach by Andrew:
#wrapper {
width: 400px;
height: 300px;
border: 1px solid red;
}
#content {
height: 125px;
border: 1px solid blue;
position: relative;
}
#content:after {
content: '';
position: absolute;
width:1px;
height: 50px;
bottom: -25px; /*half the height*/
left: 50%;
border-left: 1px solid green;
}
<div id="wrapper">
<div id="content">
</div>
</div>