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?

you can use flexbox. support

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; } 

http://jsfiddle.net/b9n3h1en/


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -