box-shadow inset leaves dark edge on a div - html

I've got a div on which i want to put an inset shadow to achieve a smooth Transition to the Background. The Problem is, that the outer most ring of Pixels is not affected by the shadow. If you take the border radius out the Problem is still present, but affects only the Bottom side of the rectangle.
https://codepen.io/FrozenYoghurt/pen/WNrjVRx
The divs do not contain anything.
.homescreen2 {
display: grid;
grid-gap: 0px;
width: 100%;
height: 100vh;
padding-top: 110px;
background-color: rgba(250,250,250,1.00);
grid-template-columns: repeat(31, 1fr);
grid-template-rows: repeat(17, 1fr);
}
.hometransition {
transition: 0.7s;
box-shadow: 0 0 15px 15px rgba(250,250,250,1) inset;
}
.homeimg01 {
grid-column-start: 10;
grid-column-end: 15;
grid-row-start: 3;
grid-row-end: 7;
background-size: cover;
background-position: center;
background-color: rgba(250,250,250,1.00);
background-image: url("https://i.postimg.cc/Jz7MbMJ3/cat-1361649-639x426.jpg");
border-radius: 50%;
}
.homeimg01:hover {
transform: scale(1.1);
border-radius: 35%;
}
.hometext01 {
grid-column-start: 10;
grid-column-end: 15;
grid-row-start: 8;
grid-row-end: 9;
}
.homeimg02 {
grid-column-start: 21;
grid-column-end: 26;
grid-row-start: 4;
grid-row-end: 8;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/bvsPBgms/cat-1362565-639x647.jpg");
border-radius: 50%;
}
.homeimg02:hover {
transform: scale(1.1);
}
.homeimg03 {
grid-column-start: 2;
grid-column-end: 7;
grid-row-start: 6;
grid-row-end: 10;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/j2rrCbt7/cat-1378752-640x480.jpg");
border-radius: 50%;
}
.homeimg03:hover {
transform: scale(1.1);
}
.homeimg04 {
grid-column-start: 26;
grid-column-end: 31;
grid-row-start: 9;
grid-row-end: 13;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/wvNp6v8z/cat-1393633-639x461.jpg");
border-radius: 50%;
}
.homeimg04:hover {
transform: scale(1.1);
}
.homeimg05 {
grid-column-start: 7;
grid-column-end: 12;
grid-row-start: 11;
grid-row-end: 15;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/wBZz8NrF/cat-1395746-640x480.jpg");
border-radius: 50%;
}
.homeimg05:hover {
transform: scale(1.1);
}
.homeimg06 {
grid-column-start: 18;
grid-column-end: 23;
grid-row-start: 12;
grid-row-end: 16;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/zGd576Ss/cat-1404368-640x512.jpg");
border-radius: 50%;
}
.homeimg06:hover {
transform: scale(1.1);
}
<div class="homescreen2">
<div class="homeimg01 hometransition"></div>
<div class="homeimg02 hometransition"></div>
<div class="homeimg03 hometransition"></div>
<div class="homeimg04 hometransition"></div>
<div class="homeimg05 hometransition"></div>
<div class="homeimg06 hometransition"></div>
</div>
I searched stackoverflows archives for a solution, but didn't find anything. I tried to cover it up with a border with the same Color as the Background and shadow, but it actually made it worse.

If you don’t want to alter the markup or use a pseudo element, you can add background-clip: content-box; padding: 1px; to hide the edge.
.homescreen2 {
display: grid;
grid-gap: 0px;
width: 100%;
height: 100vh;
padding-top: 110px;
background-color: rgba(250, 250, 250, 1.00);
grid-template-columns: repeat(31, 1fr);
grid-template-rows: repeat(17, 1fr);
}
.hometransition {
transition: 0.7s;
box-shadow: 0 0 15px 15px #fff inset;
}
.homeimg01 {
grid-column-start: 10;
grid-column-end: 15;
grid-row-start: 3;
grid-row-end: 7;
background-size: cover;
background-position: center;
background-color: rgba(250, 250, 250, 1.00);
background-image: url("https://i.postimg.cc/Jz7MbMJ3/cat-1361649-639x426.jpg");
background-clip: content-box;
padding: 1px;
}
<div class="homescreen2">
<div class="homeimg01 hometransition"></div>
</div>

Replace it with a pseudo element:
.homescreen2 {
display: grid;
grid-gap: 0px;
width: 100%;
height: 100vh;
padding-top: 110px;
background-color: rgba(250, 250, 250, 1.00);
grid-template-columns: repeat(31, 1fr);
grid-template-rows: repeat(17, 1fr);
}
.hometransition {
transition: 0.7s;
position:relative;
}
.hometransition::before {
content:"";
position:absolute;
top:-1px;
left:-1px;
right:-1px;
bottom:-1px;
border-radius:inherit;
box-shadow: 0 0 16px 16px rgba(250, 250, 250, 1) inset;
}
.homeimg01 {
grid-column-start: 10;
grid-column-end: 15;
grid-row-start: 3;
grid-row-end: 7;
background-size: cover;
background-position: center;
background-color: rgba(250, 250, 250, 1.00);
background-image: url("https://i.postimg.cc/Jz7MbMJ3/cat-1361649-639x426.jpg");
border-radius: 50%;
}
.homeimg01:hover {
transform: scale(1.1);
border-radius: 35%;
}
.hometext01 {
grid-column-start: 10;
grid-column-end: 15;
grid-row-start: 8;
grid-row-end: 9;
}
.homeimg02 {
grid-column-start: 21;
grid-column-end: 26;
grid-row-start: 4;
grid-row-end: 8;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/bvsPBgms/cat-1362565-639x647.jpg");
border-radius: 50%;
}
.homeimg02:hover {
transform: scale(1.1);
}
.homeimg03 {
grid-column-start: 2;
grid-column-end: 7;
grid-row-start: 6;
grid-row-end: 10;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/j2rrCbt7/cat-1378752-640x480.jpg");
border-radius: 50%;
}
.homeimg03:hover {
transform: scale(1.1);
}
.homeimg04 {
grid-column-start: 26;
grid-column-end: 31;
grid-row-start: 9;
grid-row-end: 13;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/wvNp6v8z/cat-1393633-639x461.jpg");
border-radius: 50%;
}
.homeimg04:hover {
transform: scale(1.1);
}
.homeimg05 {
grid-column-start: 7;
grid-column-end: 12;
grid-row-start: 11;
grid-row-end: 15;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/wBZz8NrF/cat-1395746-640x480.jpg");
border-radius: 50%;
}
.homeimg05:hover {
transform: scale(1.1);
}
.homeimg06 {
grid-column-start: 18;
grid-column-end: 23;
grid-row-start: 12;
grid-row-end: 16;
background-size: cover;
background-position: center;
background-color: black;
background-image: url("https://i.postimg.cc/zGd576Ss/cat-1404368-640x512.jpg");
border-radius: 50%;
}
.homeimg06:hover {
transform: scale(1.1);
}
<div class="homescreen2">
<div class="homeimg01 hometransition"></div>
<div class="homeimg02 hometransition"></div>
<div class="homeimg03 hometransition"></div>
<div class="homeimg04 hometransition"></div>
<div class="homeimg05 hometransition"></div>
<div class="homeimg06 hometransition"></div>
</div>

Really odd that it does that. Here's a workaround:
.homescreen2 {
display: grid;
grid-gap: 0px;
width: 100%;
height: 100vh;
background-color: rgba(250, 250, 250, 1.00);
grid-template-columns: repeat(31, 1fr);
grid-template-rows: repeat(17, 1fr);
}
.hometransition {
transition: 0.7s;
}
.homeimg01 {
grid-column-start: 2;
grid-column-end: 7;
grid-row-start: 2;
grid-row-end: 6;
background-size: cover;
background-position: center;
background-color: rgba(0, 0, 0, 1.00);
background-image: url("https://i.postimg.cc/Jz7MbMJ3/cat-1361649-639x426.jpg");
border-radius: 50%;
}
.inner {
height: 100%;
width: 100%;
box-shadow: 0 0 15px 15px rgba(250, 250, 250, 1) inset;
border-radius: 45%;
}
.homeimg01:hover {
transform: scale(1.1);
}
<div class="homescreen2">
<div class="homeimg01 hometransition">
<div class="inner"></div>
</div>
</div>
Have a div inside your image div and set the box shadow on that, then set it's border-radius to 45% instead of 50%.

Related

How to separate overlays on a hexagon grid

I have a hexagon grid and have added an overlay but the issue is all of hexagons show the same overlay. Want to see about how to separate so each hexagon will have its own overlay and I can place different words/phrases on each one. My end goal is for each hexagon to not only say something different but link to different pages. Thank ya!!!
CSS:
img {
width: 100%;
height: auto;
display: block;
object-fit: cover;
}
.hexagon-gallery {
margin: auto;
margin-top: 50px;
max-width: 1000px;
display: grid;
grid-template-columns: repeat(8, 1fr);
grid-auto-rows: 200px;
grid-gap: 14px;
padding-bottom: 50px;
}
.hex {
display: flex;
position: relative;
width: 240px;
height: 265px;
background-color: #424242;
-webkit-clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}
.hex:first-child {
grid-row-start: 1;
grid-column: 2 / span 2;
}
.hex:nth-child(2) {
grid-row-start: 1;
grid-column: 4 / span 2;
}
.hex:nth-child(3) {
grid-row-start: 1;
grid-column: 6 / span 2;
}
.hex:nth-child(4) {
grid-row-start: 2;
grid-column: 1 / span 2;
}
.hex:nth-child(5) {
grid-row-start: 2;
grid-column: 3 / span 2;
}
.hex:nth-child(6) {
grid-row-start: 2;
grid-column: 5 / span 2;
}
.hex:nth-child(7) {
grid-row-start: 2;
grid-column: 7 / span 2;
}
.hex:nth-child(8) {
grid-row-start: 3;
grid-column: 2 / span 2;
}
.hex:nth-child(9) {
grid-row-start: 3;
grid-column: 4 / span 2;
}
.hex:nth-child(10) {
grid-row-start: 3;
grid-column: 6 / span 2;
}
.container {
position: absolute;
width: 50%;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}
.container:hover .overlay {
opacity: 1;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 15%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 15px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
position: absolute;
right: 60px;
top:130px;
}
a:hover, a:active {
background-color: red;
}
<div class="container">
<section class="hexagon-gallery">
<div class="hex"><img src="img/hiw.png"> <div class="overlay">
<div class="text">Hello World</div>
This is a link
</div></div>
<div class="hex"><img src="img/wc.png"></div> <div class="overlay">
<div class="text">Hello World</div>
This is a link
</div>
<div class="hex"><img src="img/sc.png"> <div class="overlay">
<div class="text">Hello World</div>
This is a link
</div></div>
<div class="hex"><img src="img/ew.png"> <div class="overlay">
<div class="text">Hello World</div>
This is a link
</div></div>
</section>
</div>

Margin-bottom not working for image elements

The divs inside mini_projects_11 are all attached to each other, but I am providing margin-bottom. I've tried attaching margin to 'a' and also assigning 'a' display:block, but still isn't working.
style.scss
#mini_projects {
background-color: rgba(0,0,0,.85);
grid-column: 1/4;
grid-row: 1/7;
height: 100vh;
width: 100vw;
&1{
display: grid;
height: 100vh;
width: 100vw;
grid-template-columns: 20% 60% 20%;
grid-template-rows: 20% 60% 20%;
background-color: $mainDOrange;
clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
&1{
grid-column: 2/3;
grid-row: 2/3;
overflow-x: hidden;
overflow-y: scroll;
display: grid;
grid-template-columns: 50% 50%;
grid-template-rows: 40% 40%;
grid-auto-rows: 40%;
div{
justify-self: center;
height: 100%;
width: 90%;
margin-bottom:5rem; (NOT WORKING)
text-align: center;
a{
text-decoration: none;
display: block;
img{
width: 100%;
height: 100%;
border-radius: 50%;
}
span{
z-index: 1;
display: block;
color: white;
font-size: 2.5rem;
transform: translate(0rem,5rem);
}
}
}
}
}
}
#mini_projects {
background-color: rgba(0, 0, 0, .85);
grid-column: 0.25;
grid-row: 0.1428571429;
height: 100vh;
width: 100vw;
}
#mini_projects1 {
display: grid;
height: 100vh;
width: 100vw;
grid-template-columns: 20% 60% 20%;
grid-template-rows: 20% 60% 20%;
background-color: orange;
clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
}
#mini_projects11 {
grid-column: 0.6666666667;
grid-row: 0.6666666667;
overflow-x: hidden;
overflow-y: scroll;
display: grid;
grid-template-columns: 50% 50%;
grid-template-rows: 40% 40%;
grid-auto-rows: 40%;
}
#mini_projects11 div {
justify-self: center;
height: 100%;
width: 90%;
margin-bottom: 5rem;
/* (NOT WORKING) */
text-align: center;
}
#mini_projects11 div a {
text-decoration: none;
display: block;
}
#mini_projects11 div a img {
width: 100%;
height: 100%;
border-radius: 50%;
}
#mini_projects11 div a span {
z-index: 1;
display: block;
color: white;
font-size: 2.5rem;
transform: translate(0rem, 5rem);
}
<div id="mini_projects">
<div id="mini_projects1">
<div id="mini_projects11">
<div id="omnifood"><span>Omnifood</span><img src="img/omnifood.png" alt=""></div>
<div id="natours"><span>Natours</span><img src="img/natours.png" alt=""></div>
<div id="nexter"><span>Nexter</span><img src="img/nexter.png" alt=""></div>
<div id="trillo"><span>Trillo</span><img src="img/trillo.png" alt=""></div>
</div>
</div>
nevermind, I just fixed it with row-gap in #main_projects_11 .
row-gap:2rem;

Is it possible to put divs in this way?

One color on image symbolizes one div. Is it possible to put first div under second, second under third, third under fourth, and fourth under first?
Is it possible to do with pure CSS (without SVG/image etc.)?
You can also play with transform:rotate
div {
position: relative;
transform-style: preserve-3d;
perspective: 1000px;
display: grid;
grid-template-columns: 300px 300px;
grid-template-rows: 200px 200px;
}
div p {
margin: 2em;
}
div :nth-child(1),
div :nth-child(2) {
background: lightblue;
margin: 0 3em;
grid-column: 2;
grid-row: 1 / span 2;
}
div :nth-child(1) {
background: black;
grid-column: 1;
color: white;
}
div :nth-child(3),
div :nth-child(4) {
background: yellow;
margin: 2em 1em;
grid-column: 1 / span 2;
grid-row: 1;
}
div :nth-child(4) {
background: lightgreen;
grid-row: 2;
}
div :nth-child(1) {
transform: rotateX(1deg)
}
div :nth-child(2) {
transform: rotateX(-1deg)
}
<div>
<p>one</p>
<p>two</p>
<p>three</p>
<p>four</p>
</div>
Nope - tis is impossible (at least by using z-index layers) - however you can use some trick to get this effect e.g use 5 div-s:
.boxA {
position: absolute;
width: 97px;
height: 175px;
background: black;
left: 17px;
z-index: 2;
}
.boxB {
position: absolute;
width: 248px;
height: 60px;
background: yellow;
top: 32px;
z-index: 3;
}
.boxC {
position: absolute;
width: 248px;
height: 60px;
background: #00ff7b;
top: 112px;
z-index: 1;
}
.boxD {
position: absolute;
width: 62px;
height: 175px;
background: cyan;
left: 157px;
z-index: 0;
}
.boxE {
position: absolute;
width: 62px;
height: 100px;
background: cyan;
left: 157px;
z-index: 4;
}
<div class="boxA"></div>
<div class="boxB"></div>
<div class="boxC"></div>
<div class="boxD"></div>
<div class="boxE"></div>

slide does not comply with grid measurements

The id c4 is occupying row 2 / span 1, and the slider should only be taking those row also because its measurements are going from row 2 / span 1, how would I put it into the div slidecourse correctly?
#c4{
background: white;
z-index: 0;
min-height: 200vh;
min-width: 100vw;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
grid-template-rows: 20vh 60vh 5vh 15vh 15vh 85vh;
}
#c4 h1{
grid-column: 1 / -1;
grid-row: 1 / span 1;
text-align: center;
align-self: center;
font-size: 2em;
}
#c4 .textoscurso{
grid-column: 3 / span 3;
grid-row: 2 / span 1;
align-self: center;
}
#c4 .textoscurso p{
align-self: center;
}
#c4 .slidecurso{
grid-column: 7 / -1;
grid-row: 2 / span 1;
}
#c4 .slidecurso slider{
display: inline-block;
width: 100%;
height: 100%;
background: #0ff;
overflow: hidden;
position: absolute;
}
slider > *{
position: absolute;
display: block;
width: 100%;
height: 100%;
background: #0ff;
animation: slide 12s infinite;
overflow: hidden;
}
slide:nth-child(1){
left: 0;
animation-delay: -1s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide:nth-child(2){
animation-delay: 2s;
background-image: url(../img/curso.jpeg);
background-size: cover;
background-position: center;
}
slide:nth-child(3){
animation-delay: 5s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide:nth-child(4){
left: 0;
animation-delay: 8s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide p{
font-family: Comfortaa;
font-size: 70px;
text-align: center;
display: inline-block;
width: 100%;
margin-top: 100px;
color: #fff;
}
#keyframes slide{
0%{left: 100%; width: 100%;}
5%{left: 0%;}
25%{left: 0%;}
30%{left: -100%; width: 100%;}
30.0001%{left: -100%; width: 0%;}
100%{left: 100%; width: 0%;}
}
#c4 .motivos{
background: lightgray;
grid-row: 4 / span 2;
z-index: 10;
}
#c4 .moti-1{
grid-column: 2 / span 2;
}
#c4 .moti-2{
grid-column: 5 / span 2;
}
#c4 .moti-3{
grid-column: 8 / span 2;
}
#c4 .c4-2{
grid-row: 5 / -1;
grid-column: 1 / -1;
background: black;
}
<content id="c4">
<h1>Venha aprender com a gente</h1>
<div class="textoscurso">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus egestas posuere purus malesuada mattis.</div>
<div class="slidecurso">
<slider>
<slide><p>Slide 1</p></slide>
<slide><p>Slide 2</p></slide>
<slide><p>Slide 3</p></slide>
<slide><p>Slide 4</p></slide>
</slider>
</div>
<div class="motivos moti-1"></div>
<div class="motivos moti-2"></div>
<div class="motivos moti-3"></div>
<div class="c4-2"></div>
</content>
The blue slide is not correctly sized as it should and then it goes beyond the limited heigth.
I need it to be exactly inside row 2 / apan 1. Please
You need to add position:relative to the slide element since the child are set to position:absolute. In this case the width/height will be relative to that element and you won't have overflow:
I have also removed some useless properties that may create issues (min-width:100vw for example):
body {
margin:0;
}
#c4 {
background: white;
min-height: 200vh;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
grid-template-rows: 20vh 60vh 5vh 15vh 15vh 85vh;
}
#c4 h1 {
grid-column: 1 / -1;
grid-row: 1 / span 1;
text-align: center;
align-self: center;
font-size: 2em;
}
#c4 .textoscurso {
grid-column: 3 / span 3;
grid-row: 2 / span 1;
align-self: center;
}
#c4 .textoscurso p {
align-self: center;
}
#c4 .slidecurso {
grid-column: 7 / -1;
grid-row: 2 / span 1;
position: relative;
}
#c4 .slidecurso slider {
width: 100%;
height: 100%;
background: #0ff;
overflow: hidden;
position: absolute;
}
slider>* {
position: absolute;
display: block;
width: 100%;
height: 100%;
background: #0ff;
animation: slide 12s infinite;
overflow: hidden;
}
slide:nth-child(1) {
left: 0;
animation-delay: -1s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide:nth-child(2) {
animation-delay: 2s;
background-image: url(../img/curso.jpeg);
background-size: cover;
background-position: center;
}
slide:nth-child(3) {
animation-delay: 5s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide:nth-child(4) {
left: 0;
animation-delay: 8s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide p {
font-family: Comfortaa;
font-size: 70px;
text-align: center;
display: inline-block;
width: 100%;
margin-top: 100px;
color: #fff;
}
#keyframes slide {
0% {
left: 100%;
width: 100%;
}
5% {
left: 0%;
}
25% {
left: 0%;
}
30% {
left: -100%;
width: 100%;
}
30.0001% {
left: -100%;
width: 0%;
}
100% {
left: 100%;
width: 0%;
}
}
#c4 .motivos {
background: lightgray;
grid-row: 4 / span 2;
z-index: 10;
}
#c4 .moti-1 {
grid-column: 2 / span 2;
}
#c4 .moti-2 {
grid-column: 5 / span 2;
}
#c4 .moti-3 {
grid-column: 8 / span 2;
}
#c4 .c4-2 {
grid-row: 5 / -1;
grid-column: 1 / -1;
background: black;
}
<content id="c4">
<h1>Venha aprender com a gente</h1>
<div class="textoscurso">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus egestas posuere purus malesuada mattis.</div>
<div class="slidecurso">
<slider>
<slide>
<p>Slide 1</p>
</slide>
<slide>
<p>Slide 2</p>
</slide>
<slide>
<p>Slide 3</p>
</slide>
<slide>
<p>Slide 4</p>
</slide>
</slider>
</div>
<div class="motivos moti-1"></div>
<div class="motivos moti-2"></div>
<div class="motivos moti-3"></div>
<div class="c4-2"></div>
</content>

Flexbox columns multiple children

Using flex-boxes and only four divs inside the container…
I cannot handle it…
I was stack on it…
.container {
display: flex;
flex-flow: column nowrap;
}
.x-1 {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 10px 0 0;
}
.x-2 {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 10px 0 0;
}
.x-3 {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 10px 0 0;
}
.x-4 {
background: red;
height: 700px;
width: 800;
margin: 10px 10px 0 0;
}
<div class="container">
<div class="x-1"></div>
<div class="x-2"></div>
<div class="x-3"></div>
<div class="x-4"></div>
</div>
EDIT
I'll start from the beginning. I would like to get the same effect as in the image. I insert the code below.
.container {
display: flex;
padding: 0 100px;
}
.left {
display: flex;
flex-direction: column;
}
.box-1 {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 0;
}
.box-2 {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 0;
}
.box-3 {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 0;
}
.box-4 {
width: 100%;
background: red;
height: 800px;
margin: 10px 10px;
}
<div class="container">
<div class="left">
<div class="box-1"></div>
<div class="box-2"></div>
<div class="box-3"></div>
</div>
<div class="box-4"></div>
</div>
I've rewritten styles to achieve adaptivity, flexibility and maintainability:
.container {
display: flex;
/* taking margins into account, so 90px */
padding: 0 90px;
}
.left {
display: flex;
flex-direction: column;
}
.box-1,
.box-2,
.box-3,
.box-4 {
margin: 10px;
}
.box-1,
.box-2,
.box-3 {
background: yellow;
width: 200px;
height: 200px;
}
.box-4 {
background: red;
flex: 1;
height: 800px;
}
#media only screen and (max-width: 900px) {
.container {
flex-direction: column-reverse;
}
.left {
flex-direction: row;
flex-wrap: wrap;
}
.box-1,
.box-2 {
width: auto;
flex: 1 0 0;
}
.box-3 {
width: auto;
flex: 0 1 100%;
}
}
#media only screen and (max-width: 700px) {
.container {
flex-direction: column-reverse;
}
.left {
flex-direction: column;
flex-wrap: nowrap;
}
.box-1,
.box-2,
.box-3,
.box-4 {
width: auto;
flex: 1 0 auto;
}
}
<div class="container">
<div class="left">
<div class="box-1"></div>
<div class="box-2"></div>
<div class="box-3"></div>
</div>
<div class="box-4"></div>
</div>
Here is jsFiddle to test resizing.
You can wrap the yellow boxes in their own container...
.container {
display: flex;
}
.left {
display: flex;
flex-direction: column;
}
.left div[class^='x'] {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 10px 0 0;
}
.x-4 {
background: red;
height: 700px;
width: 800px;
margin: 10px 10px 0 0;
}
<div class="container">
<div class="left">
<div class="x-1"></div>
<div class="x-2"></div>
<div class="x-3"></div>
</div>
<div class="x-4"></div>
</div>
you just have to have divs to your code
.container {
display: flex;
}
.x-1 {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 10px 0 0;
}
.x-2 {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 10px 0 0;
}
.x-3 {
background: yellow;
height: 200px;
width: 200px;
margin: 10px 10px 0 0;
}
.x-4 {
background: red;
height: 700px;
width: 800px;
margin: 10px 10px 0 0;
}
<div class="container">
<div>
<div class="x-1"></div>
<div class="x-2"></div>
<div class="x-3"></div>
</div>
<div>
<div class="x-4"></div>
</div>
</div>
You can use CSS Grid layout here. Here is demo, I removed redundant .left block and rewrited styles. This will work even in IE10+:
.container {
/* taking margins into account, so 90px */
padding: 0 90px;
display: -ms-grid;
display: grid;
/* taking margins into account, so 220px */
-ms-grid-columns: 220px 1fr;
grid-template-columns: 220px 1fr;
-ms-grid-rows: auto auto 1fr;
grid-template-rows: auto auto 1fr;
}
.box-1,
.box-2,
.box-3,
.box-4 {
margin: 10px;
}
.box-1,
.box-2,
.box-3 {
background: yellow;
height: 200px;
}
.box-2 {
-ms-grid-row: 2;
grid-row: 2;
-ms-grid-column: 1;
grid-column: 1;
}
.box-3 {
-ms-grid-row: 3;
grid-row: 3;
-ms-grid-column: 1;
grid-column: 1;
}
.box-4 {
background: red;
height: 800px;
-ms-grid-row: 1;
-ms-grid-row-span: 3;
grid-row: 1 / span 3;
-ms-grid-column: 2;
grid-column: 2;
}
#media only screen and (max-width: 900px) {
.container {
-ms-grid-columns: 1fr 1fr;
grid-template-columns: 1fr 1fr;
-ms-grid-rows: 1fr auto auto;
grid-template-rows: 1fr auto auto;
}
.box-1 {
-ms-grid-row: 2;
grid-row: 2;
-ms-grid-column: 1;
grid-column: 1;
}
.box-2 {
-ms-grid-row: 2;
grid-row: 2;
-ms-grid-column: 2;
grid-column: 2;
}
.box-3 {
-ms-grid-row: 3;
grid-row: 3;
-ms-grid-column: 1;
-ms-grid-column-span: 2;
grid-column: 1 / span 2;
}
.box-4 {
-ms-grid-row: 1;
-ms-grid-row-span: 1;
grid-row: 1 / span 1;
-ms-grid-column: 1;
-ms-grid-column-span: 2;
grid-column: 1 / span 2;
}
}
#media only screen and (max-width: 700px) {
.container {
-ms-grid-columns: 1fr;
grid-template-columns: 1fr;
-ms-grid-rows: 1fr auto auto auto;
grid-template-rows: 1fr auto auto auto;
}
.box-1,
.box-2,
.box-3,
.box-4 {
-ms-grid-column: 1;
-ms-grid-column-span: 1;
grid-column: 1 / span 1;
}
.box-1 {
-ms-grid-row: 2;
grid-row: 2;
}
.box-2 {
-ms-grid-row: 3;
grid-row: 3;
}
.box-3 {
-ms-grid-row: 4;
grid-row: 4;
}
.box-4 {
-ms-grid-row: 1;
-ms-grid-row-span: 1;
grid-row: 1 / span 1;
}
}
<div class="container">
<div class="box-1"></div>
<div class="box-2"></div>
<div class="box-3"></div>
<div class="box-4"></div>
</div>
Here is jsFiddle to test resizing.