HTML Code Flexbox Responsive Photo Gallery

View the Output of this Code

 <!DOCTYPE html>

<html>

<style>

* {

  box-sizing: border-box;

}


body {

  margin: 0;

  font-family: Arial;

}


.header {

  text-align: center;

  padding: 32px;

}


.row {

  display: flex;

  flex-wrap: wrap;

  padding: 0 4px;

}


/* Create four equal columns that sits next to each other */

.column {

  flex: 25%;

  max-width: 25%;

  padding: 0 4px;

}


.column img {

  margin-top: 8px;

  vertical-align: middle;

}


/* Responsive layout - makes a two column-layout instead of four columns */

@media (max-width: 800px) {

  .column {

    flex: 50%;

    max-width: 50%;

  }

}


/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */

@media (max-width: 600px) {

  .column {

    flex: 100%;

    max-width: 100%;

  }

}

</style>

<body>


<!-- Header -->

<div class="header">

  <h1>Responsive Image Grid</h1>

  <p>Resize the browser window to see the responsive effect.</p>

</div>


<!-- Photo Grid -->

<div class="row"> 

  <div class="column">

    <img src="https://images.pexels.com/photos/5608059/pexels-photo-5608059.jpeg?cs=srgb&dl=pexels-cottonbro-5608059.jpg&fm=jpg" style="width:100%">

    <img src="https://images.pexels.com/photos/2955794/pexels-photo-2955794.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" style="width:100%">

    </div>

      <div class="column">

     <img src="https://images.pexels.com/photos/2280569/pexels-photo-2280569.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" style="width:100%; height:300px">

    <img src="https://images.pexels.com/photos/7175529/pexels-photo-7175529.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" style="width:100%; height:250px">

  

  </div>

  

  <div class="column">

    <img src="https://images.pexels.com/photos/1084071/pexels-photo-1084071.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" style="width:100%; height:300px">

    <img src="https://images.pexels.com/photos/2677814/pexels-photo-2677814.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260g" style="width:100% ; height:250px;">

   

  </div> 

   

 

</div>


</body>

</html>


Comments

Popular posts from this blog

First HTML Program