html - CSS: Responsive 3x3 grid messing up on window resize -
i'm trying make responsive 3x3 grid put noughts , crosses game on. it's working me when have maximized screen make window smaller check responsiveness messes up. what's going on? should use other vh's? http://codepen.io/apswak/pen/dxdjvw
<h3>noughts , crosses</h3> <div class="gamegrid"> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> <div class="cell"></div> </div>
style.css
body { background-color: wheat; margin: 0; padding: 0; } .gamegrid { margin: 0 auto; padding: 0; width: 62vh; height: 62vh; } .cell { margin-bottom: -5px; display: inline-block; width: 18.82vh; height: 18.82vh; border: 5px solid green; background-color: blue; }
i'd take flexbox route. i've kept gamegrid class added row class , inside each row, i've added 3 cells. don't worry naming unless want to.
.gamegrid { margin: 0 auto; padding: 0; width: 62vh; height: 62vh; background: green; } .gamegrid--row { display: flex; flex-flow: row; justify-content: space-around; } .gamegrid--cell { background: blue; margin: 5px; flex: 1 0 auto; } .gamegrid--cell:before { content: ''; float: left; padding-top: 100%; }
<div class="gamegrid"> <div class="gamegrid--row"> <div class="gamegrid--cell"></div> <div class="gamegrid--cell"></div> <div class="gamegrid--cell"></div> </div> <div class="gamegrid--row"> <div class="gamegrid--cell"></div> <div class="gamegrid--cell"></div> <div class="gamegrid--cell"></div> </div> <div class="gamegrid--row"> <div class="gamegrid--cell"></div> <div class="gamegrid--cell"></div> <div class="gamegrid--cell"></div> </div> </div>
Comments
Post a Comment