Reputation: 2649
I have 2 divs that only have the border-bottom, and a div in the middle, but bottom of the div in the middle doesn't line up with the 2 divs for some reason. How do I fix this?
body {
font-size: 0;
}
#line1 {
border-bottom: 1px solid black;
display: inline-block;
width: 25%;
}
#line2 {
border-bottom: 1px solid black;
display: inline-block;
width: 25%;
}
#box {
font-size: 18px;
border: 1px solid red;
display: inline-block;
}
<div id = 'line1'></div>
<div id = "box"> box </div>
<div id = 'line2'></div>
Upvotes: 1
Views: 50
Reputation: 2180
for style use this:
<style>
body {
font-size: 0;
}
#line1 {
font-size: 18px;
border-bottom: 1px solid black;
display: inline-block;
width: 25%;
}
#line2 {
font-size: 18px;
border-bottom: 1px solid black;
display: inline-block;
width: 25%;
}
#box {
font-size: 18px;
border: 1px solid red;
display: inline-block;
}
</style>
for html add space in line1 & line2
<body>
<div id = 'line1'> </div>
<div id = "box"> box </div>
<div id = 'line2'> </div>
</body>
Upvotes: 0
Reputation: 122047
Try this
#line2 {
border-bottom: 1px solid black;
display: inline-block;
vertical-align: bottom;
width: 25%;
}
#line1 {
border-bottom: 1px solid black;
display: inline-block;
vertical-align: bottom;
width: 25%;
}
Upvotes: 3
Reputation: 9691
You can use this css style property:
#line1, #line2, #box {
vertical-align: bottom;
}
Upvotes: 1