Search code examples
cssbootstrap-4flexboxfullscreenresponsive-images

Bootstrap4 -- fullscreen dashboard with images that resize and fill/stretch into their divs?


Been trying to get this working for a couple of days now without any luck.

This is dedicated for a larger monitor (2560x1080).. so lower viewport responsiveness doesnt matter.

I'm trying to:

  1. Make container fit large full screen edge to edge.
  2. Create a grid (i.e. like the one in attached image)
  3. Display images in that grid cells that use exactly 100% of the space available to them (based on the % values of the underlying cell/div) -- so resize with aspect ratio and then stretch or something like that.

Unfortunately every attempt is just a mess... most recently I'm using bootstrap 4 with the following extra css

https://codepen.io/jpub/pen/qBNbGOV

#mmenu_screen > .row {
    min-height: 100vh;
}
    .flex-fill {
    flex:1 1 auto;
}

Any tips would be appreciated.

It should look like this.......

*** EXAMPLE TARGET LAYOUT IMAGE ***


Solution

  • no bootstrap or framework needed CSS grid got you covered ;) it's a simple API read the CSS and you will understand how does it work you just add the needed divs then you give it literally a template and he will arrange them for you it's 100% responsive (to the limit for sure of the content).

    • to control the images use a background image and size with percentage with "background-size" ;)

    hope I have helped

    .grid-container {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
    
      display: grid;
      grid-template-areas:
        'area1 area1 area1 area1 area4 area4'
        'area1 area1 area1 area1 area5 area5'
        'area2 area2 area3 area3 area6 area6'
        'area2 area2 area3 area3 area7 area7';
      grid-gap: 10px;
      
      background-color: #f9fad2;
      padding: 10px;
    
    }
    
    .grid-container > div {
      background-color: #18bc9c;
      text-align: center;
      padding: 20px 0;
      font-size: 30px;
    }
    
    
    
    .item1 { grid-area: area1;  background-image: url("https://www.bmw.in/content/dam/bmw/marketIN/bmw_in/Images/all-models/BMW%20Series/bmw-2-series/Main%20Banner%20Desktop.jpg/_jcr_content/renditions/cq5dam.resized.img.1680.large.time1601620546255.jpg");  background-size: cover;  }
    .item2 { grid-area: area2; }
    .item3 { grid-area: area3; }
    .item4 { grid-area: area4; }
    .item5 { grid-area: area5; }
    .item6 { grid-area: area6;  }
    .item7 { grid-area: area7;  background-image: url("https://cdn.cnn.com/cnnnext/dam/assets/190815154638-01-bugatti-centodieci-exlarge-169.jpg");    background-repeat: no-repeat;
      background-size: 100% 100%; }
    <div class="grid-container">
      <div class="item1">1</div>
      <div class="item2">2</div>
      <div class="item3">3</div>  
      <div class="item4">4</div>
      <div class="item5">5</div>
       <div class="item6">6</div>
      <div class="item7">7</div>
    </div>