Responsive div blocks - html

I have 6 blocks in a row like that:
In mobile and desktop version everything works as I want, but when I change flex-direction from row to column:
In the desktop version, everything works well, but on the mobile version, blocks do not arrange 2 in each row, they are in a column. How can I solve that?
CSS:
* {
box-sizing: border-box;
}
img {
width: auto;
max-width: 100%;
height: auto;
max-height: 100%;
}
.picture-box {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
padding: 3rem 1.5rem;
}
.ring {
flex: 0 0 calc(50% - 10px);
padding: 20px;
margin-bottom: 20px;
border: 1px solid green;
text-align: center;
}
.thumb {
display: inline-block;
max-width: 200px;
padding: 10px;
border: 1px solid blue;
}
#media all and (min-width: 1024px) {
.ring {
flex: 0 0 calc((100% / 3) - (40px / 3))
}
}
#media all and (min-width: 1240px) {
.ring {
flex: 0 0 calc((100% / 6) - (100px / 6))
}
}
HTML:
<div class="picture-box">
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
</div>

What about using the desktop media query to keep the column layout and use the flex-direction : row for mobile and tablet ?
#media all and (min-width: 1024px) {
.ring {
flex: 0 0 calc((100% / 3) - (40px / 3))
}
.picture-box {
flex-direction: column;
}
}
See this fiddle

Please use, https://getbootstrap.com/ framework .
and use html structure like this,
<div class="picture-box">
<div class="row">
<div class="col-sm-2">
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
</div>
<div class="col-sm-2">
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
</div>
<div class="col-sm-2">
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
</div>
<div class="col-sm-2">
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
</div>
<div class="col-sm-2">
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
</div>
<div class="col-sm-2">
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
</div>
<div class="col-sm-2">
<div class="ring">
<div class="thumb">
<img src="https://via.placeholder.com/200">
</div>
</div>
</div>
</div>
</div>

Please you can try this....
<style>
body{padding: 0px;margin: 0px;}
*{box-sizing: border-box;}
img{width: auto;max-width: 100%;}
.picture-box{display: flex;flex-direction: row;justify-content:space-around; padding: 3rem 1.5rem;}
.ring{padding: 20px;margin:0px 10px 20px 10px;border: 1px solid green;text-align: center;}
.thumb{display: block;padding: 10px;border: 1px solid blue;}
#media(max-width: 1024px){.picture-box{flex-wrap: wrap;}.ring{width: calc(33.3% - 20px);}}
#media(max-width: 768px){.ring{width: calc(50% - 20px);}}
#media(max-width: 480px){.ring{width: 100%; margin: 0px 0px 20px 0px;}}
</style>

Related

How to create this css grid

I want to acheive this design any next category will automatically adjust to the previous div. Every category have not specific product but need to just after the previous product like we use float left or display-flex But don't want to create multiple css for responsive. Because it has more than 25 categories. `
.offerpage .product-box {
margin: 0 5px;
}
.categoryProductsWrap{
width: 100%;
}
.product-img{
width: 100%;
}
.categoryProductsWrap .categoryProducts {
display: flex;
flex-wrap: wrap;
width: 100%;
}
.categoryProductsWrap .categoryProducts .product-box {
margin-bottom: 10px;
float: left;
}
.offerpage .categoryName {
color: #161719;
font-size: 24px;
font-weight: bold;
margin-bottom: 0.5em;
border-bottom: solid 1px #dddddd;
padding-bottom: 0.125em;
}
.img-box{
position: relative;
padding-top: 124%;
display: inline-block;
width: 100%;
vertical-align: top;
}
.product-box .product-img{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
}
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}
.txt-content {
overflow: hidden;
position: relative;
}
.img-box{
position: relative;
padding-top: 124%;
display: inline-block;
width: 100%;
vertical-align: top;
}
.offerpage{
display: flex;
flex-wrap: wrap;
}
.categoryProductsWrap .categoryProducts .product-box{
width: 33.333%
}
#media (min-width: 1200px){
.categoryProductsWrap.cooling_fan {
width: 50%;
}
.categoryProductsWrap.accessories {
width: 50%;
}
}
#media (min-width: 1440px){
.categoryProductsWrap.accessories .categoryProducts .product-box,
.categoryProductsWrap.cooling_fan .categoryProducts .product-box {
width: calc(50% - 10px);
}
}
<div class="offerpage">
<div class="categoryProductsWrap accessories">
<div class="categoryName">Accessories</div>
<div class="categoryProducts clearfix offerzone-slider products-wrapper">
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="categoryProductsWrap cooling_fan">
<div class="categoryName">Cooling Fan</div>
<div class="categoryProducts clearfix offerzone-slider products-wrapper">
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="categoryProductsWrap asus">
<div class="categoryName">Asus</div>
<div class="categoryProducts clearfix offerzone-slider products-wrapper">
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="categoryProductsWrap audio">
<div class="categoryName">Audio Device</div>
<div class="categoryProducts clearfix offerzone-slider products-wrapper">
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
<div class="product-box">
<div class="product-inner-box">
<div class="txt-content">
<div class="img-box">
<a href="#" class="product-thumbnail">
<img class="product-img img-responsive" src="https://picsum.photos/400">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`
If you want to use CSS grid, there no big difficulties simply check the documentation to understand the main CSS properties you need to add.
Also check this guide on CSS grid to undertand more and see examples.
Quick help
If I understand correctly you want 3 items max per row, to do that you will need to set:
grid-template-columns: repeat(3, 1fr);
The equivalent to flex-direction: row; is grid-auto-flow: row;
You will I presume also need a gap (spacing between items), something like that:
gap: 10px;
So a good starting point will be:
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-auto-flow: row;
gap: 10px;
I leave you do the rest according to your needs.

How do i add a title on top of a thumbnail?

It's not my proudest moment to say that I am struggling with this since yesterday, I managed to make my gallery thumbnails look almost like the model in the picture that I uploaded, but I can't add the "image title" section. I managed at some point to put a title and the gray background, but when I hovered on it, only the image moved and not the title. Please help me so I can get rid of this problem once and forever (Thank you for your time):
<head>
<style>
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
gap: 20px;
background: rgb(255, 255, 255);
padding: 15px;
}
.box > img {
width: 80%;
display: block;
background-color: cornflowerblue;
border-radius: 12%;
}
.container img:hover {
transform: scale(1.04);
}
</style>
</head>
<body>
<div class="container">
<div class="box">
<img src="placeholder-image.png">
<span>daa</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>Image</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>rrrr</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
<div class="box">
<img src="placeholder-image.png">
<span>strike</span>
</div>
</div>
</body>
If you want the hover styling to apply to the title text and the image, just use transform on the .box container hover state instead of only the image with .container img:hover. This way both the <img> and the <span> text will "move as one" since they are both children of the .box parent container. Try this out.
.box {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
}
.box .title {
background: #ddd;
padding: .5rem 1rem;
text-align: center;
width: -webkit-fill-available;
border-bottom-left-radius: .5rem;
border-bottom-right-radius: .5rem;
}
<style>
.container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
gap: 20px;
background: rgb(255, 255, 255);
padding: 15px;
}
img {
max-width: 100%;
}
.box > img {
width: 100%;
display: block;
background-color: cornflowerblue;
border-top-right-radius: 1rem;
border-top-left-radius: 1rem;
/* border-radius: 12%;*/
}
.box:hover {
transform: scale(1.04);
}
</style>
</head>
<body>
<div class="container">
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
<div class="box">
<img src="https://static.thenounproject.com/png/17840-200.png" alt="some alt text">
<div class="title">
<span>Image Title</span>
</div>
</div>
</div>
</body>

css issue when using language switcher

My page
I have installed a language switcher plugin, from LTR to RTL. in this page their is a raw html raw
THE ISSUE: when i switch the language to RTL the boxes goes to the extreme right and extreme left
what to add so when the user switches the language the boxes would have the same alignment as the english version
Code:
<div class="vc_row wpb_row vc_row-fluid" style="background: white;">
<div class="wpb_column vc_column_container vc_col-sm-12">
<div class="vc_column-inner">
<div class="wpb_wrapper">
<div class="vc_empty_space" style="height: 32px"><span class="vc_empty_space_inner"></span></div>
<div class="vc_empty_space" style="height: 32px"><span class="vc_empty_space_inner"></span></div>
<div class="widget-text-heading no-line">
<h3 class="title">
<span>WHY INVEST IN</span>
DUBAI ? </h3>
</div>
<div class="widget widget-features-box default">
<div class="content">
<div class="row">
<div class="col-xs-12 col-sm-6 box-align1">
<div class="feature-box box-model">
<div class="feature-box-inner">
<div class="fbox-icon">
<div class="icon-inner ">
<img class="img" src="https://new.universalprime.co/wp-content/uploads/2020/01/Asset-5#2x.png" alt="">
</div>
</div>
<div class="fbox-content ">
<h3 class="ourservice-heading">EXPO 2020</h3>
<div class="description">It expected that roughly 28 million people will visit Dubai by Expo 2020</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 box-align2">
<div class="feature-box box-model">
<div class="feature-box-inner">
<div class="fbox-icon">
<div class="icon-inner ">
<img class="img" src="https://new.universalprime.co/wp-content/uploads/2020/01/Asset-2#2x.png" alt="">
</div>
</div>
<div class="fbox-content ">
<h3 class="ourservice-heading">MULTI-SECTORED ECONOMY</h3>
<div class="description">65% of global investment and a multi-sectored economy that does not rely on oil.</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 box-align1">
<div class="feature-box box-model">
<div class="feature-box-inner">
<div class="fbox-icon">
<div class="icon-inner ">
<img class="img" src="https://new.universalprime.co/wp-content/uploads/2020/01/Asset-8#2x.png" alt="">
</div>
</div>
<div class="fbox-content ">
<h3 class="ourservice-heading">INVESTMENT-FRIENDLY</h3>
<div class="description">A safe country for investment, supported with 0% income tax policy and facilitated by laws that ease business creation.</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 box-align2">
<div class="feature-box box-model">
<div class="feature-box-inner">
<div class="fbox-icon">
<div class="icon-inner ">
<img class="img" src="https://new.universalprime.co/wp-content/uploads/2020/01/Asset-7#2x.png" alt="">
</div>
</div>
<div class="fbox-content ">
<h3 class="ourservice-heading">PASSPORT RECOGNITION</h3>
<div class="description" style="margin: 0 0 26px 0;">The strongest Passport
<br>world-wide</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 box-align1">
<div class="feature-box box-model">
<div class="feature-box-inner">
<div class="fbox-icon">
<div class="icon-inner ">
<img class="img" src="https://new.universalprime.co/wp-content/uploads/2020/01/Asset-3#2x.png" alt="">
</div>
</div>
<div class="fbox-content ">
<h3 class="ourservice-heading">GLOBAL HUB</h3>
<div class="description">Dubai airport is considered the 3rd most visited in the world, they celebrated the 1 Billionth traveler in 2018</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-6 box-align2">
<div class="feature-box box-model">
<div class="feature-box-inner">
<div class="fbox-icon">
<div class="icon-inner ">
<img class="img" src="https://new.universalprime.co/wp-content/uploads/2020/01/Asset-6#2x.png" alt="">
</div>
</div>
<div class="fbox-content ">
<h3 class="ourservice-heading">RELIABLE INVESTMENT</h3>
<div class="description">Investments worth 37 Billion AED from Gulf residents. Total transactions reached 111 Billion in Dubai 2018.</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<style>
.description {
margin: 0 0 20px 0;
}
.icon-inner{
background:#fff !important;
box-shadow:none;
}
#media only screen and (max-width: 767px) {
.col-xs-12 {
padding: 0px 14%;
}
}
#media only screen and (min-width: 768px) {
.col-sm-6 {
height: 240px;
width: 25%;
margin: 23px 12%;
background: whitesmoke;
box-shadow: 2px 2px 30px -6px #8e99a3;
margin-bottom: 80px;
}
.box-model {
position: absolute;
top: -95px;
left: 10%;
width: 80%;
}
.box-align1{
right:-80px !important;
}
.box-align2{
left:-80px !important;
}
.title{
margin-bottom:80px !important;
}
}
#media only screen and (min-width: 992px) {
.col-sm-6 {
height: 238px;
width: 25%;
margin: 23px 12%;
background: whitesmoke;
box-shadow: 2px 2px 30px -6px #8e99a3;
margin-bottom: 90px;
}
.box-model {
position: absolute;
top: -95px;
left: 10%;
width: 80%;
}
.box-align1{
right:-105px !important;
}
.box-align2{
left:-105px !important;
}
.title{
margin-bottom:80px !important;
}
}
#media only screen and (min-width: 1141px) {
.col-sm-6 {
width: 25%;
margin: 23px 12%;
background: whitesmoke;
box-shadow: 2px 2px 30px -6px #8e99a3;
height: 230px !important;
margin-bottom: 100px;
}
.box-model {
position: absolute;
top: -95px;
width: 80%;
left: 10%;
}
.box-align1{
right:-126px !important;
}
.box-align2{
left:-126px !important;
}
.title{
margin-bottom:80px !important;
}
}
#media only screen and (min-width: 1141px) {
.box-align1{
right:-114px !important;
}
.box-align2{
left:-114px !important;
}
}
#media only screen and (min-width: 1200px) {
.box-align1{
right:-125px !important;
}
.box-align2{
left:-125px !important;
}
}
#media only screen and (min-width: 1290px) {
.box-align1{
right:-162px !important;
}
.box-align2{
left:-162px !important;
}
}
</style>

Images showing issue

I have total 20 images of products. I want to show these images like 1st product should be on left side and related images of that product on right hand side. Remaining products should come under 1st product column wise on the left hand side.
Currently, I am trying to do so but it is now coming properly. I am not good with CSS though. Could someone tell me what I am doing wrong?
Below is my code.
HTML
for all products images
<mat-card class="example-card" fxFlex="60%;" fxFlex.xs="80%">
<div class="grid" *ngIf="resultData">
<div class="item photo" *ngIf="anums[0]">
<img class="photothumb" [src]="resultData[0]" (click)="openImageDialogbox(resultData[0])" onError="this.src='/assets/kein-bild.gif';">
<div class="desc">
<p [routerLink]="['/rullko/produkt/', werbedata.FILIALE + werbedata.ArtNr_01]">Zum Produkt {{ anums[0] }}</p>
</div>
</div>
<div class="item photo" *ngIf="anums[1]">
<img class="photothumb" [src]="resultData[1]" (click)="openImageDialogbox(resultData[1])" onError="this.src='/assets/kein-bild.gif';">
<div class="desc">
<p [routerLink]="['/rullko/produkt/', werbedata.FILIALE + werbedata.ArtNr_02]">Zum Produkt {{ anums[1] }}</p>
</div>
</div>
<div class="item photo" *ngIf="anums[2]">
<img class="photothumb" [src]="resultData[2]" (click)="openImageDialogbox(resultData[2])" onError="this.src='/assets/kein-bild.gif';">
<div class="desc">
<p [routerLink]="['/rullko/produkt/', werbedata.FILIALE + werbedata.ArtNr_03]">Zum Produkt {{ anums[2] }}</p>
</div>
</div>
</div>
</mat-card>
For image of first product (like logo, supporting images etc)
<div class="grid">
<div class="item photo" *ngIf="secondImage">
<img class="photothumb" [src]="secondImage" onError="this.src='/assets/kein-bild.gif';">
<div class="desc">
<p>Bild 2
</div>
<div class="item photo" *ngIf="thirdImage">
<img class="photothumb" [src]="thirdImage" onError="this.src='/assets/kein-bild.gif';">
<div class="desc">
<p>Bild 3</p>
</div>
</div>
<div class="item photo" *ngIf="fourthImage">
<img class="photothumb" [src]="fourthImage" onError="this.src='/assets/kein-bild.gif';">
<div class="desc">
<p>Bild 4</p>
</div>
</div>
<div class="item photo" *ngIf="logo">
<img class="photothumb" [src]="logo" onError="this.src='/assets/kein-bild.gif';">
<div class="desc">
<p>Logo</p>
</div>
</div>
<div class="item photo" *ngIf="brandImage">
<img class="photothumb" [src]="brandImage" onError="this.src='/assets/kein-bild.gif';">
<div class="desc">
<p>Siegel</p>
</div>
</div>
</div>
</div>
CSS
.grid {
display: grid;
grid-gap: 5px;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
grid-auto-rows: 150px;
/* flex-direction: row wrap; */
}
.item {
background-color: #ffffff;
margin: 10px;
width: 300px;
}
.photothumb {
max-width: 200px;
max-height: 200px;
cursor: pointer;
}
.desc {
padding: 10px 10px 5px 10px;
cursor: pointer;
}
.desc img {
width: 50%;
margin: 0 10px 10px 0;
float: left;
}
.desc p {
margin-bottom: 10px;
font-family: 'Arial';
font-size: 15px;
}
.photo {
grid-row-end: span 2;
}
Solution which I did :
<mat-card class="example-card" fxFlex="60%;" fxFlex.xs="80%">
<div class='some-page-wrapper'>
<div class='row'>
<div class='column'>
<div class='blue-column' *ngIf="anums[0]">
<img [src]="resultData[0]" (click)="openImageDialogbox(resultData[0])" onError="this.src='/assets/noImage.png';">
<div class="desc">
<p [routerLink]="['/rullko/produkt/', werbedata.FILIALE + werbedata.ArtNr_01]">Zum Produkt {{ anums[0] }}</p>
</div>
</div>
</div>
<div class='green-column' *ngIf="secondImage">
<img [src]="secondImage" (click)="openImageDialogbox(secondImage)" onError="this.src='/assets/noImage.png';">
<div class="desc">
<p>Bild 2</p>
</div>
</div>
</div>
</div>
</mat-card>
CSS:
.some-page-wrapper {
margin: 15px;
}
.row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 100%;
}
.column {
display: flex;
flex-direction: column;
flex-basis: 100%;
flex: 1;
}

Metro grid style

I'm trying to achieve something like the following page:
https://undsgn.com/uncode/homepages/blog-metro/
I have tried and was able to come as close as this: https://jsfiddle.net/futu7t1c/
But how can I get those 2 small-thumbs at the bottom to move up?
The order is big, small, small, big, small, small
<div id="blog-posts">
<div class="grid big-thumb">
Title
</div>
<div class="grid small-thumb">
Title
</div>
<div class="grid small-thumb">
Title
</div>
<div class="grid big-thumb">
Title
</div>
<div class="grid small-thumb">
Title
</div>
<div class="grid small-thumb">
Title
</div>
</div>
css
#blog-posts {
-moz-column-count: 1;
-webkit-column-count: 1;
column-count: 1;
-moz-column-gap: 0em;
-webkit-column-gap: 0em;
column-gap: 0em;
}
.grid {
background: #eee;
float: left;
position: relative;
color: #fff;
}
.big-thumb {
width: 50%;
height: 600px;
background: #aeaeae;
}
.small-thumb {
width: 25%;
height: 300px;
background: #353535;
}
To replicate that grid, you can make flex rows that have flex children that are also flex columns holding your images.
.flex {
display: flex;
}
.col {
flex-direction: column;
flex: 0 0 50%;
}
img {
max-width: 100%;
vertical-align: top;
}
<div class="flex row">
<div class="flex col">
<div class="big">
<img src="http://1.bp.blogspot.com/-hNC-oT6f-fY/TeXxO26yjvI/AAAAAAAAAOY/qfkOqdKkBi8/s1600/platon-photographer-putin-man-of-the-year-portrait.jpg">
</div>
<div class="flex row">
<div class="small">
<img src="https://i.stack.imgur.com/2C22p.jpg">
</div>
<div class="small">
<img src="https://i.stack.imgur.com/2C22p.jpg">
</div>
</div>
</div>
<div class="flex col">
<div class="flex row">
<div class="small">
<img src="https://i.stack.imgur.com/2C22p.jpg">
</div>
<div class="small">
<img src="https://i.stack.imgur.com/2C22p.jpg">
</div>
</div>
<div class="big">
<img src="http://1.bp.blogspot.com/-hNC-oT6f-fY/TeXxO26yjvI/AAAAAAAAAOY/qfkOqdKkBi8/s1600/platon-photographer-putin-man-of-the-year-portrait.jpg">
</div>
</div>
Well, that's how you'd do it using regular ol' html/css. But since you want to just have a bunch of elements that automatagically lay out like that, use masonry
$('.masonry').masonry({
itemSelector: '.item',
columnWidth: '.small'
});
body {
margin: 0;
}
.item {
float: left;
}
.big {
width: 50%;
}
.small {
width: 25%;
}
img {
width: 100%;
vertical-align: top;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://unpkg.com/masonry-layout#4/dist/masonry.pkgd.min.js"></script>
<div class="masonry">
<div class="item big">
<img src="http://1.bp.blogspot.com/-hNC-oT6f-fY/TeXxO26yjvI/AAAAAAAAAOY/qfkOqdKkBi8/s1600/platon-photographer-putin-man-of-the-year-portrait.jpg">
</div>
<div class="item small">
<img src="https://i.stack.imgur.com/2C22p.jpg">
</div>
<div class="item small">
<img src="https://i.stack.imgur.com/2C22p.jpg">
</div>
<div class="item big">
<img src="http://1.bp.blogspot.com/-hNC-oT6f-fY/TeXxO26yjvI/AAAAAAAAAOY/qfkOqdKkBi8/s1600/platon-photographer-putin-man-of-the-year-portrait.jpg">
</div>
<div class="item small">
<img src="https://i.stack.imgur.com/2C22p.jpg">
</div>
<div class="item small">
<img src="https://i.stack.imgur.com/2C22p.jpg">
</div>
</div>