SASS fade_in effect problems to watch - css

I am trying to get a differents divs with gradients color, from darker to lighter.
I can watch how my code edit lighter the color, but i can't watch the darker effect. I review the code and all are working correctly. The fade_out effect is working, but not the fade_in effect - at it is identical. When I review the css file generated, i watch that the background-color are the same that the $color-base value. Why the fade_in effect is not appreciating?
SCSS:
#if $k==1 {
$color-base: red;
}
#else if $k==2 {
$color-base: blue;
}
#else {
$color-base: green;
}
.container-#{$k} {
.base-color {
background-color: $color-base;
}
#for $i from 4 through 1 {
.darken-#{$i} {
background-color: fade_in($color-base, 0.2 * $i);
.color-box-text {
color: red;
}
}
.lighten-#{$i} {
background-color: fade_out($color-base, 0.2 * $i);
.color-box-text {
color: black;
}
}
}
}
}
HTML:
<div class="box darken-4"><span class="color-box-text">Darken 4</span></div>
<div class="box darken-3"><span class="color-box-text">Darken 3</span></div>
<div class="box darken-2"><span class="color-box-text">Darken 2</span></div>
<div class="box darken-1"><span class="color-box-text">Darken 1</span></div>
<div class="box base-color"><span class="color-box-text">Base color</span></div>
<div class="box lighten-1"><span class="color-box-text">Lighten 1</span></div>
<div class="box lighten-2"><span class="color-box-text">Lighten 2</span></div>
<div class="box lighten-3"><span class="color-box-text">Lighten 3</span></div>
<div class="box lighten-4"><span class="color-box-text">Lighten 4</span></div>
</div>
<div class="mycontainer container-2">
<div class="box darken-4"><span class="color-box-text">Darken 4</span></div>
<div class="box darken-3"><span class="color-box-text">Darken 3</span></div>
<div class="box darken-2"><span class="color-box-text">Darken 2</span></div>
<div class="box darken-1"><span class="color-box-text">Darken 1</span></div>
<div class="box base-color"><span class="color-box-text">Base color</span></div>
<div class="box lighten-1"><span class="color-box-text">Lighten 1</span></div>
<div class="box lighten-2"><span class="color-box-text">Lighten 2</span></div>
<div class="box lighten-3"><span class="color-box-text">Lighten 3</span></div>
<div class="box lighten-4"><span class="color-box-text">Lighten 4</span></div>
</div>
<div class="mycontainer container-3">
<div class="box darken-4"><span class="color-box-text">Darken 4</span></div>
<div class="box darken-3"><span class="color-box-text">Darken 3</span></div>
<div class="box darken-2"><span class="color-box-text">Darken 2</span></div>
<div class="box darken-1"><span class="color-box-text">Darken 1</span></div>
<div class="box base-color"><span class="color-box-text">Base color</span></div>
<div class="box lighten-1"><span class="color-box-text">Lighten 1</span></div>
<div class="box lighten-2"><span class="color-box-text">Lighten 2</span></div>
<div class="box lighten-3"><span class="color-box-text">Lighten 3</span></div>
<div class="box lighten-4"><span class="color-box-text">Lighten 4</span></div>
</div>

The function fade-in() is doing the same as opacify() and according to the documentation:
The opacify() function increases the alpha channel by a fixed amount.
Your $color-base values are all opaque and therefore the fade-in() function doesn't apply since their alpha channels have already the max value. If you try with a base color with an alpha value lower than 1 you will see that your code works fine.

Related

Overflow Scroll not working on MacOS Safari 13 and below

I have a category menu and list of projects whereby on the main tag we have
margin-top: 250px;
height: calc(100vh - 250px);
From the above, if the projects' container has a height bigger than calc(100vh - 250px), then by default it's scrollable.
If the projects' container has a height smaller than calc(100vh - 250px), then we flex-end everything (menu, container) to the bottom of the page. The projects container has overflow-y: scroll;
This is working perfectly in all browsers except MacOS (Catalina) Safari 13 and below.
In Safari 13, all the projects that are supposed to be scrollable are reduced in height to fit the available height calc(100vh - 250px).
Normal and expected view
Faulty view Safari 13, using https://testingbot.com/ to test
You can view the page here https://category-scrollings.tiiny.site/ (Free trial expiring in 7 days).
const panels = Array.from(document.querySelectorAll(".projects-container"));
const menus = Array.from(document.querySelectorAll(".nav-item"));
menus.forEach(function (menu) {
menu.addEventListener("click", function (event) {
console.log("event:", event.target);
menus.forEach(function (_menu, index) {
const _panel = panels[index];
_menu.classList.remove("clicked");
_panel.classList.remove("active");
});
const panelId = `${event.target.id.split("-")[0]}-panel`;
const panel = document.getElementById(panelId);
event.target.classList.add("clicked");
panel.classList.add("active");
});
});
body {
height: 100vh;
overflow: hidden;
}
main {
display: flex;
-webkit-box-pack: start;
justify-content: flex-start;
align-items: flex-start;
width: 100%;
}
.container {
display: flex;
margin-top: 250px;
flex-direction: column;
-webkit-box-pack: end;
justify-content: flex-end;
align-items: flex-start;
width: calc(50vw - 25px);
height: calc(100vh - 250px);
}
.nav {
display: flex;
flex-direction: row;
-webkit-box-pack: start;
justify-content: flex-start;
top: 200px;
-webkit-box-align: center;
align-items: center;
padding: 6px 0px;
background-color: rgb(255, 255, 255);
position: sticky;
z-index: 1000;
width: 100%;
}
.nav-item {
cursor: pointer;
font-size: 0.688rem;
line-height: 1.334rem;
margin: 0px;
font-family: "ABC Favorit", sans-serif;
color: #ccc;
text-transform: uppercase;
letter-spacing: 0.6px;
font-weight: 600;
margin-right: 16px;
}
.nav-item.clicked {
color: #000;
}
.projects-container.active {
display: flex;
}
.projects-container {
display: none;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: end;
-ms-flex-pack: end;
-webkit-justify-content: flex-end;
justify-content: flex-end;
-webkit-align-items: flex-center;
-webkit-box-align: flex-center;
-ms-flex-align: flex-center;
align-items: center;
height: auto;
width: 100%;
overflow-y: scroll;
padding-bottom: 20px;
}
.projects {
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: start;
-ms-flex-pack: start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
-webkit-align-items: flex-start;
-webkit-box-align: flex-start;
-ms-flex-align: flex-start;
align-items: flex-start;
width: 100%;
overflow-y: scroll;
}
.project {
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: 100%;
border-top: 0.9px solid #d9d9d9;
}
.boxes {
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: start;
-ms-flex-pack: start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
width: auto;
cursor: pointer;
min-width: 140px;
}
.box {
display: block;
height: 27px;
width: 7px;
}
.box.blue {
background-color: blue;
}
.box.white {
background-color: white;
}
.box.yellow {
background-color: yellow;
}
.box.red {
background-color: red;
}
.box.black {
background-color: black;
}
.title-container {
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-pack: start;
-ms-flex-pack: start;
-webkit-justify-content: flex-start;
justify-content: flex-start;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
max-width: 355px;
width: 100%;
cursor: pointer;
padding: 9px 0;
}
.title {
margin: 0;
color: #000;
font-family: "ABC Favorit", sans-serif;
max-width: 255px;
width: 100%;
font-size: 0.875rem;
font-weight: 400;
text-transform: uppercase;
line-height: 0.875rem;
margin-top: 1.7px;
margin-left: 50px;
margin-right: 50px;
}
<main>
<div class="container">
<div class="nav">
<div id="all-menu" class="nav-item clicked">All</div>
<div id="cars-menu" class="nav-item">Cars</div>
<div id="fashion-menu" class="nav-item">Fashion</div>
</div>
<div id="all-panel" class="projects-container all active">
<div class="projects">
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">IULH VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ULHF VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">UYJHF VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">UYJHF VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">UYJHF VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">UYJHF VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">UYJHF VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ALIUIYF VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">HEYsh VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">YTKGUIY VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">rjke VERBINDEN</p>
</div>
</div>
</div>
</div>
<div id="cars-panel" class="projects-container cars">
<div class="projects">
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ZUKUNFT VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">AMDILK VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">IULH VERBINDEN</p>
</div>
</div>
</div>
</div>
<div id="fashion-panel" class="projects-container fashion">
<div class="projects">
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">UYJHF VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">ALIUIYF VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">HEYsh VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">YTKGUIY VERBINDEN</p>
</div>
</div>
<div class="project">
<div class="boxes">
<div class="box blue"></div>
<div class="box yellow"></div>
<div class="box white"></div>
<div class="box red"></div>
<div class="box black"></div>
</div>
<div class="title-container">
<p class="title">rjke VERBINDEN</p>
</div>
</div>
</div>
</div>
</div>
</main>
Click Expand Snippet to see all
I have figured out the answer myself. It appears I needed to assign a height to the project class
// either
.project {
...
height: 35px;
}
// Or
.project {
...
min-height: fit-content;
height: 100%;
}

Select the second element of the second section with same name, CSS - NTH

In this example http://jsfiddle.net/rodrigolinkweb/k8qg14xL/ I need to select only "Container 12", how can I do this?
ps: note that both divs have the same class name "wrapper".
.container:nth-child(n+3){
background-color: gray;
color:white;
}
<div class="wrapper">
<div class="container">Container 1</div>
<div class="container">Container 2</div>
<div class="container">Container 3</div>
</div>
<br />
<div class="wrapper">
<div class="container">Container 11</div>
<div class="container">Container 12</div>
<div class="container">Container 13</div>
</div>
You can select them with the .wrapper class, like this
.wrapper:nth-of-type(2) .container:nth-child(2){
background-color: gray;
color:white;
}
<div class="wrapper">
<div class="container">Container 1</div>
<div class="container">Container 2</div>
<div class="container">Container 3</div>
</div>
<br />
<div class="wrapper">
<div class="container">Container 11</div>
<div class="container">Container 12</div>
<div class="container">Container 13</div>
</div>
If you want to select it from backwards you can use :nth-last-of-type() . Refer to the following fiddle here
No matter what content the .wrapper has :nth-child will select child based on its position where as :nth-of-type selects with appropriate attribute.
.wrapper:nth-of-type(2) .container:nth-child(2){
background-color: gray;
color:white;
}
<div class="wrapper">
<div class="container">Container 1</div>
<div class="container">Container 2</div>
<div class="container">Container 3</div>
</div>
<br />
<div class="wrapper">
Some link
<div class="container">Container 12</div>
<div class="container">Container 13</div>
</div>

Rows of divs not lining up correctly

Question regarding styling. I have a row of div elements. They're all the same size except one, which is double in height and width. I'd like the second row of div elements to line up with the second half of the bigger div but now sure how to do it.
.wrapper {
width: 800px;
display: flex;
flex-wrap: wrap;
flex-direction: row;
}
.box {
height: 50px;
width: 50px;
margin: 5px;
border: 1px solid black;
}
.box-5 {
height: 100px;
width: 100px
}
<div class="wrapper">
<div class="box box-1">Box 1</div>
<div class="box box-2">Box 2</div>
<div class="box box-3">Box 3</div>
<div class="box box-4">Box 4</div>
<div class="box box-5">Box 5</div>
<div class="box box-6">Box 6</div>
<div class="box box-7">Box 7</div>
<div class="box box-8">Box 8</div>
<div class="box box-9">Box 9</div>
<div class="box box-10">Box 10</div>
<div class="box box-11">Box 11</div>
<div class="box box-12">Box 12</div>
<div class="box box-13">Box 13</div>
<div class="box box-14">Box 14</div>
<div class="box box-15">Box 15</div>
<div class="box box-16">Box 16</div>
<div class="box box-17">Box 17</div>
<div class="box box-18">Box 18</div>
<div class="box box-19">Box 19</div>
</div>
I'd like box 13 - 16 to be on the left side of the bottom half of box 5 and box 17 - 19 to be on the right side.
You could use CSS display: grid and its companion grid-template-columns to fix this. Updated answer thanks to Maaz Syed Adeeb's comment.
grid-template-columns: repeat(13, auto);
(It should be thirteen instead of 12 boxes).
Only box number 5 gets an upgrade in styling to expand its box:
grid-column: span 2;
grid-row: span 2;
Read more about grid at MDN.
Updated snippet:
.wrapper {
width: 100%;
height: 100%;
display: grid;
grid-template-columns: repeat(13, auto);
grid-template-rows: auto;
grid-gap: 0;
}
.box {
height: 50px;
width: 50px;
margin: 5px;
border: 1px solid black;
}
.box-5 {
height: 100px;
width: 100px;
grid-column: span 2;
grid-row: span 2;
}
<div class="wrapper">
<div class="box box-1">Box 1</div>
<div class="box box-2">Box 2</div>
<div class="box box-3">Box 3</div>
<div class="box box-4">Box 4</div>
<div class="box box-5">Box 5</div>
<div class="box box-6">Box 6</div>
<div class="box box-7">Box 7</div>
<div class="box box-8">Box 8</div>
<div class="box box-9">Box 9</div>
<div class="box box-10">Box 10</div>
<div class="box box-11">Box 11</div>
<div class="box box-12">Box 12</div>
<div class="box box-13">Box 13</div>
<div class="box box-14">Box 14</div>
<div class="box box-15">Box 15</div>
<div class="box box-16">Box 16</div>
<div class="box box-17">Box 17</div>
<div class="box box-18">Box 18</div>
<div class="box box-19">Box 19</div>
</div>
Just need to add 10 more pixel in width
.box-5 {
height: 100px;
width: 110px;
}
.wrapper{
width: 800px;
display: flex;
flex-wrap: wrap;
flex-direction: row;
}
.box{
height: 50px;
width: 50px;
margin: 5px;
border: 1px solid black;
}
.box-5 {
height: 100px;
width: 110px;
}
<div class="wrapper">
<div class="box box-1">Box 1</div>
<div class="box box-2">Box 2</div>
<div class="box box-3">Box 3</div>
<div class="box box-4">Box 4</div>
<div class="box box-5">Box 5</div>
<div class="box box-6">Box 6</div>
<div class="box box-7">Box 7</div>
<div class="box box-8">Box 8</div>
<div class="box box-9">Box 9</div>
<div class="box box-10">Box 10</div>
<div class="box box-11">Box 11</div>
<div class="box box-12">Box 12</div>
<div class="box box-13">Box 13</div>
<div class="box box-14">Box 14</div>
<div class="box box-15">Box 15</div>
<div class="box box-16">Box 16</div>
<div class="box box-17">Box 17</div>
<div class="box box-18">Box 18</div>
<div class="box box-19">Box 19</div>
</div>

How can i create a responsive grid design like shown in an image?

Here is some of my CSS code which I am using to create shadow boxes inside the grid view. I tried to find HTML something like rowspan and colspan but I did't got any idea.
.box{
width: 100%;
height: 240px;
background: white;
border-color: black;
border-width: 2px;
-webkit-box-shadow: -1px 2px 5px 1px rgba(10,0,10,1);
-moz-box-shadow: -1px 2px 5px 1px rgba(10,0,10,1);
box-shadow: -1px 2px 5px 1px rgba(10,0,10,1);
};
You can create columns with Bootstrap Grid system. You can try following structural.
<div class="container">
<div class="row">
<div class="col-sm-8">
<div class="box h-100">Box 1</div>
</div>
<div class="col-sm-4">
<div class="box mb-3">Box 2</div>
<div class="box mb-3">Box 3</div>
<div class="box mb-3">Box 4</div>
<div class="box">Box 5</div>
</div>
</div>
<div class="row my-3">
<div class="col-sm-4">
<div class="box">Box 6</div>
</div>
<div class="col-sm-4">
<div class="box">Box 7</div>
</div>
<div class="col-sm-4">
<div class="box">Box 8</div>
</div>
</div>
<div class="row my-3">
<div class="col-sm-4">
<div class="box">Box 9</div>
</div>
<div class="col-sm-4">
<div class="box">Box 10</div>
</div>
<div class="col-sm-4">
<div class="box">Box 11</div>
</div>
</div>
</div>

Bootstrap creating a row with 4 boxes

Hi guys I'm using bootstrap 3 and trying to crate this effect here :
However i cant seem to create this using bootstrap at all Mine keep lying under each other, Any help on recreating this format would be great
HTML:
<div id="night">
<div class="container">
<div class="row">
<div class="col-xs-3 col-md-6 first">
<p>a</p>
</div>
</div>
<div class="row">
<div class="col-xs-3 col-md-3 first">
<p>a</p>
</div>
<div class="col-xs-3 col-md-3 first">
<p>a</p>
</div>
</div>
<div class="row">
<div class="col-xs-3 col-md-3 first">
<p>a</p>
</div>
<div class="col-xs-3 col-md-3 first">
<p>a</p>
</div>
</div>
</div>
</div>
css:
.first {
border-style: solid;
border-color: red;
}
Thanks
Try this please
<div id="night">
<div class="container">
<div class="row">
<div class="col-md-4 first">
<div class="second">a</div>
</div>
<div class="col-md-4 first">
<div class="third">a</div>
<div class="third">a</div>
</div>
<div class="col-md-4 first">
<div class="third">a</div>
<div class="third">a</div>
</div>
</div>
</div>
</div>
CSS:
.first {
border-style: solid;
border-color: red;
}
.second {
border-style: solid;
border-color: blue;
display: block;
height: 400px;
}
.third {
border-style: solid;
border-color: blue;
display: block;
height: 200px;
}
This works in full page, maybe you can work with this aproximation:
<div class="container">
<div class="row">
<div class="col-sm-4" style="background-color:yellow;">
1
</div>
<div class="col-sm-8" style="background-color:pink;">
<div class="row">
<div class="col-sm-6" style="background-color:blue;">
2
</div>
<div class="col-sm-6" style="background-color:red;">
3
</div>
<div class="col-sm-6" style="background-color:green;">
4
</div>
<div class="col-sm-6" style="background-color:black;">
5
</div>
</div>
</div>
</div>
</div>

Resources