Using flex to layout image one by one - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Flex

Description

Using flex to layout image one by one

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.box {<!--from w  w  w . j  ava  2 s. c  o m-->
   border:2px solid Chartreuse;
   width:100%;
   display:flex;
   margin-bottom:16px;
}

.box:after {
   content:"";
   display:table;
   clear:both;
}

.box .image {
   float:left;
   width:61%;
   border-right:2px solid yellow;
   display:flex;
   align-items:center;
   flex-wrap:wrap;
   padding:6px;
}

.box .image a {
   text-decoration:none;
}

.box .image a:not(:last-of-type) {
   margin-right:6px;
}

.box .image2 {
   width:61%;
   border-right:2px solid blue;
   display:flex;
   align-items:center;
   flex-wrap:nowrap;
   padding:6px;
}

.box .image2 a {
   text-decoration:none;
}

.box .image2 a:not(:last-of-type) {
   margin-right:6px;
}

.box .tools {
   float:left;
   width:41%;
   padding:6px;
}
</style> 
 </head> 
 <body> 
  <div class="box"> 
   <div class="image"> 
    <a href="#"> <img src="https://www.java2s.com/style/demo/Firefox.png"> </a> 
    <a href="#"> <img src="https://www.java2s.com/style/demo/Opera.png"> </a> 
    <a href="#"> <img src="https://www.java2s.com/style/demo/Safari.png"> </a> 
    <a href="#"> <img src="https://www.java2s.com/style/demo/Firefox.png"> </a> 
   </div> 
   <div class="tools"> 
    <a href="#">View details</a> 
   </div> 
  </div> 
  <div class="box"> 
   <div class="image2"> 
    <a href="#"> <img src="https://www.java2s.com/style/demo/Firefox.png"> </a> 
    <a href="#">Lorem ipsum dolor sit amet, consectetur adipisicing dolor sit amet, consectetur.</a> 
   </div> 
   <div class="tools"> 
    <a href="#">View details</a> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials