html - How to align 3 divs to the top middle and bottom of a page? -
i need align 3 divs top, middle , bottom of webpage below current code.
<div class="container"> <div class="logo"> logo </div> <div class="nav"> nav </div> <div class="base"> base </div> </div>
i have tried using table/table-cell method each section sits side side.
the container needs fixed , nav should vertically aligned.
any ideas make logo div @ top, nav div in middle , base div @ bottom?
you css table, added <div>
each block.
html, body { height: 100%; margin: 0; } .container { background: gold; width: 100%; height: 100%; display: table; } .container .row { display: table-row; } .container .cell { display: table-cell; } .logo .cell { vertical-align: top; } .nav .cell { vertical-align: middle; } .base .cell { vertical-align: bottom; }
<div class="container"> <div class="row logo"> <div class="cell">my logo</div> </div> <div class="row nav"> <div class="cell">my nav</div> </div> <div class="row base"> <div class="cell">base</div> </div> </div>
you make flexbox layout.
body { margin: 0; } .container { background: gold; height: 100vh; display: flex; flex-direction: column; justify-content: space-between; }
<div class="container"> <div class="row logo">logo</div> <div class="row nav">nav</div> <div class="row base">base</div> </div>
Comments
Post a Comment