html - How to center two square blocks in page? -
i have page i'm displaying status of 2 websites -- in if they're , running, or not. if site up, want block have light green background, , if not, light red one. , site's name should centered inside block.
this i've tried far:
body { font-family: sans-serif; } #container { width: 800px; height: 600px; margin: 0 auto; border: 1px solid #ccc; } #smallcontainer { width: 208px; height: 100px; margin: 200px auto auto; } .status { height: 100px; width: 100px; background: #efefef; float: left; margin-left: 2px; border: 1px solid #ccc; }
<div id="container"> <div id="smallcontainer"> <div class="status"></div> <div class="status"></div> </div> </div>
it works (see full screen output), feel i'm way off. how do simple using css, correct way? feel code hack. , how write text in center of block, vertically , horizontally?
and possible have such way works across desktop screen sizes? maybe should specify width , height in percentage opposed pixels?
html
<div id="container"> <div class="status"></div> <div class="status"></div> </div>
css
#container { width: 800px; height: 600px; margin: 0 auto; border: 1px solid #ccc; display: flex; align-items: center; justify-content: center; } .status { height: 100px; width: 100px; background: #efefef; margin-left: 2px; border: 1px solid #ccc; }
Comments
Post a Comment