css - I'm trying to center text in the middle of my page HTML -
i have 3 different div tags (not inside each other) code has 1 puts words left, center, or right center off centered. here html code:
.desc { float: right; color: skyblue; } .desc1 { float: left; color: skyblue; } .desc2 { text-align: center; color: skyblue; }
<div class="desc1"> <h2>what here do!</h2> <p>example</p> </div> <div class="desc2"> <h2>what have completed</h2> <p>recent work (can include pictures)</p> </div> <div class="desc"> <h2>company description</h2> <p>example!</p> </div>
you can use flexbox fix that,
html:
<div class="container"> <div class="desc1"> <h2>what here do!</h2> <p>example</p> </div> <div class="desc2"> <h2>what have completed</h2> <p>recent work (can include pictures)</p> </div> <div class="desc"> <h2>company description</h2> <p>example!</p> </div> </div>
css:
.container{ display: flex; align-items: center; justify-content: space-between; }
Comments
Post a Comment