html - Responsive vertical center elements inside div -


i need verticaly align elements inside div container. elements looks on image below. code, able nicely overwrap big picture on left, text , small picture still doing wants. need avoid flexbox, since need support ie8, or atleast ie9. i've been trought several solutions, tables or absolute positions, propably i've did wrong...

thank helping me of :)

responsive vertical center elements

html

    <section class="contact">         <div class="adress">             <h4>abc</h4>             <span>acbd<br>             efgh</span>             <span>tyre<br>             asdsad<br>             cxzcasd</span>             <img src="img/ccc-map.png" alt="map-ccc">         </div>         <div class="map">             <img src="img/ccc-g-map.png" alt="google-map">         </div>     </section> 

scss

.contact {     border: 1.5px solid $grey;      width: 100%;      .adress {         float: left;         width: 40%;         padding: 2%;          h4 {             font-size: 130%;         }          span {             font-size: 100%;         }          img {             width: 45%;             height: auto;         }     }     .map {         float: right;         width: 60%;         padding: 1%;          img {             width: 100%;             height: auto;         }     }  } .contact::after {     content: " ";     display: table;     clear: both; } 

you're mixing block-level elements h4 , inline img , expecting them align properly, possible there's simpler solution, add third cell:

.contact{    display: table;    width: 100%;    border-collapse: collapse;    border: 2px solid #ddd;  }  .contact > div{    display: table-cell;    vertical-align:middle;    padding:8px;  }  .contact img{    vertical-align: middle;    width: 100%;  }  .pic{    width: 100px;  }  .map{    width: 60%;  }
<section class="contact">        <!-- create 3 cells instead! -->        <div class="adress">      <h4>abc</h4>       <span>        acbd<br>        efgh      </span>      <span>        tyre<br>        asdsad<br>        cxzcasd      </span>    </div>        <div class="pic">      <img src="//placehold.it/100x100/fac" alt="map-ccc">    </div>        <div class="map">      <img src="//placehold.it/500x300/fac" alt="google-map">    </div>      </section>


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

c# SetCompatibleTextRenderingDefault must be called before the first -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -