I have a set of 3 identical divs
with fixed width. Each contains text of varying lengths and another nested div
that is aligned to the right using float.
When the text lengths are equal, they align perfectly. However, when the text lengths differ, the alignment gets thrown off. I've experimented with different settings but none seem to work. My goal is to have them all align horizontally regardless of text length!
What could be causing this issue?
.con {
width: 300px;
height: 200px;
display: inline-block;
background: #996600;
text-align: left;
margin: 0px;
padding: 0px;
}
.box {
width: 150px;
height: 150px;
background-color: #333333;
position: relative;
float: right;
margin: 0px;
padding: 0px;
}
.main {
text-align: center;
}
<div class="main">
<h1 class="topic"> Topic goes here </h1>
<div class="con">
<div class="box"></div>
<p class="para">My short text</p>
</div>
<div class="con">
<div class="box"></div>
<p class="para">My average length text that doesn't align properly</p>
</div>
<div class="con">
<div class="box"></div>
<p class="para">My long text that causes alignment issues due to extra length</p>
</div>
</div>
</div>