Custom Responsive grid column sizes not sizing properly - html

Ok. Long time reader first time poster. So I have been trying to create a custom grid system so I don't have to rely on frameworks such as bootstrap or boilerplate all the time. I have got the grid working but, When a col-12x is above another col-12x. The first columns still has 15px of padding on the right, and some columns don't have the padding on the right of the last column in a row. The text wont break the same as it is for identical columns. I have attached a link to a [JSFIDDLE][1] since S.O wont let me put in the css for some reason.
<div class="grid-fw">
<div class="row">
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
<div class="col-1xs"><p>col-1</p></div>
</div>
<div class="row">
<div class="col-6xs"><p>col-6</p></div>
<div class="col-4xs"><p>col-4</p></div>
<div class="col-2xs"><p>col-2</p></div>
</div>
<div class="row">
<div class="col-6xs col-8lg">
<div class="col-8xs"><p>col-8</p></div>
<div class="col-4xs"><p>col-4</p></div>
</div>
<div class="col-6xs col-4lg"><p>col-8</p></div>
</div>
<div class="row">
<div class="col-4xs"><p>col-4</p></div>
<div class="col-4xs"><p>col-4</p></div>
<div class="col-4xs"><p>col-4</p></div>
</div>
<div class="row">
<div class="col-12xs"><p>col-12</p></div>
<div class="col-12xs"><p>col-12</p></div>
</div>
</div>
I have a feeling that its the same issue for both things, but its driving me crazy. Any help would be greatly appreciated.

because col-12* it is your max # of columns (like bootstrap), so you can only have one for each .row (given your current CSS) where you state:
/* Floats last ".col-" to the right */
[class*='col-']:last-of-type { padding-right: 0; }
having two col-12* in one .row will make the 1st col-12* to have your default padding-right:10px as you state here
/* Column attribute selector */
[class*='col-'] { position: relative; float: left; padding-right: 10px; min-height: 1px; }
Snippet
/* Grid Container */
.grid,
.grid-fw {
padding: 15px;
margin: 0 auto;
}
/* Phones */
#media (min-width: 420px) {
.grid {
width: 400px;
}
}
/* Mobile */
#media (min-width: 768px) {
.grid {
width: 750px;
}
}
/* Tablet */
#media (min-width: 992px) {
.grid {
width: 970px;
}
}
/* Desktop */
#media (min-width: 1200px) {
.grid {
width: 1170px;
}
}
/* Clearfix */
.row:after,
.row:before {
content: "";
display: table;
clear: both !important;
}
/* Column attribute selector */
[class*='col-'] {
position: relative;
float: left;
padding-right: 10px;
min-height: 1px;
}
/* Floats last ".col-" to the right */
[class*='col-']:last-of-type {
padding-right: 0;
}
/* Phones Grid Columns */
#media only screen and (max-width: 420px) {
[class*='col-'] {
width: 100%;
padding-right: 0;
}
}
/* Grid Columns Mobile First */
#media (min-width: 321px) {
.col-1xs {
width: 8.33333333%;
}
.col-2xs {
width: 16.66666667%;
}
.col-3xs {
width: 25%;
}
.col-4xs {
width: 33.33333333%;
}
.col-5xs {
width: 41.66666667%;
}
.col-6xs {
width: 50%;
}
.col-7xs {
width: 58.33333333%;
}
.col-8xs {
width: 66.66666667%;
}
.col-9xs {
width: 75%;
}
.col-10xs {
width: 83.33333333%;
}
.col-11xs {
width: 91.66666667%;
}
.col-12xs {
width: 100%;
}
}
/* Tablet Grid Columns Mobile First */
#media (min-width: 768px) {
.col-1sm {
width: 8.33333333%;
}
.col-2sm {
width: 16.66666667%;
}
.col-3sm {
width: 25%;
}
.col-4sm {
width: 33.33333333%;
}
.col-5sm {
width: 41.66666667%;
}
.col-6sm {
width: 50%;
}
.col-7sm {
width: 58.33333333%;
}
.col-8sm {
width: 66.66666667%;
}
.col-9sm {
width: 75%;
}
.col-10sm {
width: 83.33333333%;
}
.col-11sm {
width: 91.66666667%;
}
.col-12sm {
width: 100%;
}
}
/* Laptop Grid Columns */
#media (min-width: 992px) {
.col-1md {
width: 8.33333333%;
}
.col-2md {
width: 16.66666667%;
}
.col-3md {
width: 25%;
}
.col-4md {
width: 33.33333333%;
}
.col-5md {
width: 41.66666667%;
}
.col-6md {
width: 50%;
}
.col-7md {
width: 58.33333333%;
}
.col-8md {
width: 66.66666667%;
}
.col-9md {
width: 75%;
}
.col-10md {
width: 83.33333333%;
}
.col-11md {
width: 91.66666667%;
}
.col-12md {
width: 100%;
}
}
/* Desktop Grid Columns */
#media (min-width: 1200px) {
.col-1lg {
width: 8.33333333%;
}
.col-2lg {
width: 16.66666667%;
}
.col-3lg {
width: 25%;
}
.col-4lg {
width: 33.33333333%;
}
.col-5lg {
width: 41.66666667%;
}
.col-6lg {
width: 50%;
}
.col-7lg {
width: 58.33333333%;
}
.col-8lg {
width: 66.66666667%;
}
.col-9lg {
width: 75%;
}
.col-10lg {
width: 83.33333333%;
}
.col-11lg {
width: 91.66666667%;
}
.col-12lg {
width: 100%;
}
}
/* Removes padding behaviour on widths */
*,
*:after,
*:before {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/* Clearfix for Nested Rows */
.clearfix {
clear: both;
}
/* Show Columns */
[class*='col-'] > p {
background-color: #004d81;
padding: 10px;
border-radius: 4px;
margin-bottom: 10px;
font-size: 0.8rem;
text-align: center;
color: #fff;
}
<div class="grid-fw">
<div class="row">
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
<div class="col-1xs">
<p>col-1</p>
</div>
</div>
<div class="row">
<div class="col-6xs">
<p>col-6</p>
</div>
<div class="col-4xs">
<p>col-4</p>
</div>
<div class="col-2xs">
<p>col-2</p>
</div>
</div>
<div class="row">
<div class="col-6xs col-8lg">
<div class="col-8xs">
<p>col-8</p>
</div>
<div class="col-4xs">
<p>col-4</p>
</div>
</div>
<div class="col-6xs col-4lg">
<p>col-8</p>
</div>
</div>
<div class="row">
<div class="col-4xs">
<p>col-4</p>
</div>
<div class="col-4xs">
<p>col-4</p>
</div>
<div class="col-4xs">
<p>col-4</p>
</div>
</div>
<div class="row">
<div class="col-12xs">
<p>col-12</p>
</div>
</div>
<div class="row">
<div class="col-12xs">
<p>col-12</p>
</div>
</div>
</div>

Related

Responsive Outlook mail footer with CSS

To create a responsive html signature, I tried the infamous <style scoped> tag. As far as I understood there's a conflict with #media queries. Is there a better way to achieve this in a way I can use it in MS Outlook client, preferably both on PC and smartphone?
Here's a reduced version of what I have:
<style scoped>
#containter {
width: 100%;
height: 250px;
}
#firm-contact {
width: 35%;
float: left;
}
#firm-links {
width: 290px;
float: left;
}
#firm-logo {
margin: 2% 4% 1% 4%;
width: 165px;
float: left;
}
/* screenwitdh <= 980px */
#media screen and (max-width: 980px) {
#containter {
height: 580px;
}
#firm-contact {
width: 41%;
}
#firm-links {
width: 41%;
float: right;
}
#firm-logo {
clear: both;
width: auto;
float: none;
}
}
/* screenwitdh <= 600px */
#media screen and (max-width: 600px) {
#containter {
height: 680px;
}
...
}
</style>
<div id="footer">
<div id="display">
<div id="containter">
<div id="firm-contact">
<p>Streer</p>
<p>Place</p>
<p>+tel</p>
</div>
<div id="firm-links">
<p><span>Links</span><</p>
<p><Something</p>
<p>Other</p>
</div>
<div id="firm-logo">
<div width="250" heigth="250">
<img class="img-fluid" src="img/some.png" alt="Logo" width="75%">
</div>
</div>
</div> <!-- containter -->
</div> <!-- display -->
</div> <!-- footer -->

Padding-bottom/top hack for responsive blocks with different widths

Good day.
I have the following task: I want to build a grid of cards (for example - news), which will keep their proportions with a change of browser's width. For this reason I decided to use aspect-ratio hack for setting card's height (setting padding-top).
This solution works fine for cards with the same width. But my design uses ordinary cards and double.
I chose the "desktop-first" strategy. So my goal is to save cards' proportions with start height - 300px.
So, in my design, I have ordinary card with start size: width: 380px and height: 300px. And double card with start size: width: 780px and height: 300px.
For each case I counted the values for padding-top. For ordinary card: 300/380 = 0,7894736842105263, so padding-top: 78.94836842105263%. For double card: 300/780 = 0,3846153846153846, so padding-top: 38.46153846153846%.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: sans-serif;
background-color: #f0f0f0;
color: #323232;
}
.container {
max-width: 1600px;
margin-right: auto;
margin-left: auto;
padding-left: 10px;
padding-right: 10px;
}
.row {
margin: 0 -10px;
}
.row::before, .row::after {
display: table;
content: '';
}
.row::after {
clear: both;
}
.col {
float: left;
width: 100%;
padding: 0 10px;
}
#media (min-width: 768px) {
.col--regular {
width: 50%;
}
}
#media (min-width: 920px) {
.col--regular {
width: 33.3333%;
}
.col--doubled {
width: 66.6666%;
}
}
#media (min-width: 1220px) {
.col--regular {
width: 25%;
}
.col--doubled {
width: 50%;
}
}
.card {
position: relative;
margin-bottom: 20px;
background-position: center;
background-size: cover;
}
.card__title {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding: 10px;
font-size: 18px;
font-weight: 700;
}
.card--regular {
padding-top: 78.94836842105263%;
}
.card--doubled {
padding-top: 38.46153846153846%;
}
<div class="container">
<div class="row">
<div class="col col--doubled">
<div class="card card--doubled" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Big card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
</div>
</div>
But if you look at the working example, you will see that double card has a greater height than regular when we change browser's width. So this breaks the grid.
Please tell me what my mistake is. Or how to solve this situation.
Link to example: https://codepen.io/dimitrysh/pen/jZBOzJ
UPD: developers from https://ru.insider.pro/ managed to achieve such result. Please check this "example".
Thank you in advance!
Interesting question ...
If you want the heights to be exactly equal, you need to calculate them the same way. So, lets make col--doubled the same width than col--regular.
Now, the padding trick wroks the same for both.
The car--doubled will need to have width: 200%. And we need to adjust the spacing, setting an adequate margin to col-doubled.
On a side note: May be you could consider switching to a grid display.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: sans-serif;
background-color: #f0f0f0;
color: #323232;
}
.container {
max-width: 1600px;
margin-right: auto;
margin-left: auto;
padding-left: 10px;
padding-right: 10px;
}
.row {
margin: 0 -10px;
}
.row::before, .row::after {
display: table;
content: '';
}
.row::after {
clear: both;
}
.col {
float: left;
width: 100%;
padding: 0 10px;
}
#media (min-width: 768px) {
.col--regular {
width: 50%;
}
}
#media (min-width: 920px) {
.col--regular {
width: 33.3333%;
}
.col--doubled {
width: 33.3333%;
margin-right: 33.33%;
}
}
#media (min-width: 1220px) {
.col--regular {
width: 25%;
}
.col--doubled {
width: 25%;
margin-right: 25%;
}
}
.card {
position: relative;
margin-bottom: 20px;
background-position: center;
background-size: cover;
}
.card__title {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding: 10px;
font-size: 18px;
font-weight: 700;
}
.card--regular, .card--doubled {
padding-top: 78.94836842105263%;
}
.card--doubled {
width: calc(200% + 20px);
}
<div class="container">
<div class="row">
<div class="col col--doubled">
<div class="card card--doubled" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Big card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular" style="background-image: url('https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80');">
<div class="card__title">
Regular card title
</div>
</div>
</div>
</div>
</div>
I found, as it seems to me, a flexible solution of the problem.
The trick is to use the flexbox module for strings.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: sans-serif;
background-color: #f0f0f0;
color: #323232;
}
.container {
max-width: 1180px;
margin-right: auto;
margin-left: auto;
padding-left: 10px;
padding-right: 10px;
}
.row {
margin: 0 -10px;
}
.row::before, .row::after {
display: table;
content: '';
}
.row::after {
clear: both;
}
.col {
float: left;
width: 100%;
padding: 0 10px;
overflow: hidden;
}
#media (min-width: 768px) {
.col--regular {
width: 50%;
}
}
#media (min-width: 920px) {
.col--regular {
width: 33.3333%;
}
.col--double {
width: 66.6666%;
}
}
#media (min-width: 1220px) {
.col--regular {
width: 25%;
}
.col--double {
width: 50%;
}
}
.card {
position: relative;
margin-bottom: 20px;
background-position: center;
background-size: cover;
background-image: url("https://images.unsplash.com/5/unsplash-kitsune-4.jpg?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=bc01c83c3da0425e9baa6c7a9204af81&auto=format&fit=crop&w=1350&q=80");
overflow: hidden;
}
.card__title {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding: 10px;
font-size: 18px;
font-weight: 700;
}
.card--regular {
padding-top: 78.94836842105263%;
}
.card--double {
padding-top: 38.46153846153846%;
}
.flex-container {
width: 100%;
}
.flex-container .flex-row {
width: 100%;
display: flex;
justify-content: flex-start;
align-items: stretch;
flex-wrap: wrap;
}
<div class="container flex-container">
<div class="row flex-row">
<div class="col col--double">
<div class="card card--double">
<div class="card__title">
Big card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular">
<div class="card__title">
Regular card title
</div>
</div>
</div>
<div class="col col--regular">
<div class="card card--regular">
<div class="card__title">
Regular card title
</div>
</div>
</div>
</div>
</div>
Pay attention to css-classes flex-container, flex-row.
Thus we will stretch the cards according to the height of the highest card.

How to make that grid?

Do you know how to make the grid like this?
I tried to create that with margins to make white spaces. However, it doesn't work for first <div> because it has own height and margin [%].
.block {
height: 270px;
width: 47%;
margin: 1.5%;
display: block;
float: left;
}
.blockbig {
width: 97%;
margin: 1.5%;
height: 540px;
display: block;
float: left;
}
.blockw {
width: 97%;
margin: 1.5%;
height: 270px;
display: block;
float: left;
}
.rectagle {
height: 550px;
width: 47%;
margin: 1.5%;
display: block;
float: left;
}
.row1 {
width: 50%;
float: left;
}
#media (max-width: 1160px) {
.container {
width: 90%;
}
}
#media (max-width: 900px) {
#b4 {
clear: both;
}
.block {
width: 28.83%;
}
}
<div class="container">
<div class="row1">
<div class="">
<div id="b1" class="rectagle" style="background-color: Beige;">1</div>
<div id="b2" class="block" style="background-color: orange;">2</div>
<div id="b6" class="block" style="background-color: blue;">6</div>
</div>
<div id="b7" class="blockbig" style="background-color: black;">7</div>
</div>
<div class="row1">
<div id="b3" class="block" style="background-color: black;">3</div>
<div id="b4" class="block" style="background-color: orange;">4</div>
<div id="b5" class="blockbig" style="background-color: Aquamarine">5</div>
<div id="b8" class="blockw" style="background-color: Azure ;">8</div>
</div>
</div>
View on JSFiddle
My attempt looks like this:
I would be nice if it's responsive.
Here is the template, which I have to convert.
Ok, I made that.
* {
box-sizing: border-box;
}
#b1 {
display: block;
float: left;
width: 25%;
height: 540px;
}
#b2, #b3, #b4, #b6 {
display: block;
float: left;
width: 25%;
height: 270px;
}
#b5, #b7 {
display: block;
width: 50%;
height: 540px;
}
#b5 {
float: right;
}
#b7 {
float: left;
}
#b8 {
display: block;
float: left;
width: 50%;
height: 270px;
}
.row1 {
width: 100%;
}
#media (max-width: 1160px) {
.container {
width: 90%;
}
.container1 {
width: 100%;
}
#media (max-width: 850px) {
#b1, #b7 {
height: 428px;
}
#b2, #b3, #b4, #b6 {
height: 214px;
}
#b1, #b2, #b3, #b4, #b6 {
width: calc(100%/3);
}
#b5, #b8 {
height: 214px;
}
}
#media (max-width: 640px) {
#b1, #b2, #b3, #b4, #b6, #b7, #b5 {
width: 50%;
}
#b7 {
height: 214px;
}
#b8 {
width: 100%;
}
}
#media (max-width: 480px) {
#b1, #b2, #b3, #b4, #b6, #b7, #b5, #b8 {
width: 100%;
height: 400px;
}
}
<div class="container1">
<div class="row1">
<div id="b1" class="inline-block" style="background-color: Beige;"><div class="block-content">1</div></div>
<div id="b2" class="inline-block" style="background-color: orange;"><div class="block-content">2</div></div>
<div id="b3" class="inline-block" style="background-color: black;"><div class="block-content">3</div></div>
<div id="b4" class="inline-block" style="background-color: orange;"><div class="block-content">4</div></div>
<div id="b6" class="inline-block" style="background-color: blue;"><div class="block-content">6</div></div>
<div id="b5" class="inline-block" style="background-color: Aquamarine"><div class="block-content">5</div></div>
<div id="b7" class="inline-block" style="background-color: black;"><div class="block-content">7</div></div>
<div id="b8" class="inline-block" style="background-color: Azure ;"><div class="block-content">8</div></div>
</div>
</div>
However, with border-box, I do not know how to use padding to add white spaces [10px] around all blocks.

Div is under other divs

I'm trying to put a form on a div where I have an image:Form on the image
The problem is that I cannot float the form to the right side and also the form is under the other divs just as the image I've also attached here:
Form under other divs
.slider__size {
overflow: hidden;
height: 570px;
position: relative;
font-family: "DINNextLTProLight";
}
.slider__img__position {
justify-content:center;
align-items:center;
display: flex;
position: absolute;
}
.slider__consolidado__img__position {
justify-content:center;
align-items:right;
display: flex;
position: absolute;
}
.img-responsive, .thumbnail a>img, .thumbnail>img {
display: block;
height: auto;
margin: auto;
position: relative;
}
.title__box {
padding-top:200px;
position: absolute;
padding-left: 50px;
}
.h1__home span{
color: white;
font-size: 50px;
letter-spacing: 1px;
font-weight: bolder;
}
#media (min-width: 600px) and (max-width: 992px) {
.img-responsive, .thumbnail a>img, .thumbnail>img {
max-width: 150%;
height: auto;
position: relative;
margin: auto;
}
}
#media (min-width: 400px) and (max-width: 600px) {
.img-responsive, .thumbnail a>img, .thumbnail>img {
max-width: 250%;
}
}
#media (max-width: 400px) {
.img-responsive, .thumbnail a>img, .thumbnail>img {
max-width: 300%;
height: auto;
position: relative;
margin: auto;
}
#media (max-width: 300px) {
.img-responsive, .thumbnail a>img, .thumbnail>img {
max-width: 400%;
}
}
}
#media (min-width: 768px) {
.navbar-fixed-bottom { display: none;}
}
#media (min-width:768px){
.form__consolidado__color {
margin-top: 120px;
position: absolute;
margin-left: 20px;
box-shadow: 0 0 6px 0px black;
}
}
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-sm-12 slider__size">
<div class="slider__consolidado__img__position">
<img class="img-responsive img__blend__filter" src="/slider_notebook.jpeg"
alt="Crédito Família">
</div>
<div class="title__box">
<h1 class="h1__home"><span>Comece<br>a realizar<br>sonhos</span</h1>
<button class="btn-default btn-padding btn__slider__color_orange">
Saiba mais
</button>
</div>
</div>
<div class="col-xs-12 col-sm-6 form__consolidado__color">
<h2 class="form__title">Lorem Ipsum</h2>
<h3 class="form__subtitle">What's Lorem Ipsum</h3>
<form data-toggle="validator" role="form" name="contato" action="" method="POST">
<div class="form-group row">..... </div>
<div class="row">
<div class="col-sm-12 div__info__color">
<h2 class="text__blue__h2">.....</h2>
<p class="text__grey__14">......</p>
</div>
The problem of the form being under other divs can be solved by setting the "z-index" property of the div containing the form to a high value which will make the form appear on the first level
z-index: 100
.col-xs-12.col-sm-6.form__consolidado__color {
float: right;
}
I solved the float problem with margin-left:45%;

Custom Css Grid with Vanilla Css (No Framework)

I'm trying to get a div element that is split in half and in one of the halfs, have 4 equal square boxes.
So far I think I have the initial set up but when I try to produce the 4 squares within one of the halfs one overflows past the other leaving both halfs not equal. I hope the code snippet might help
<!DOCTYPE html>
<html>
<head>
<title> Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
*, *:after, *:before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
border: 0;
background: gray;
min-width: 100%;
}
.container {
min-width: 100%;
margin: 0 auto;
padding: 4px ;
}
[class*="col-"] {
float: left;
padding: 0;
margin: 0;
border: 0;
width:inherit
}
/* GRID SYSTEM */
.row::after {
content: '';
clear: both;
display: block;
}
#media only screen
and (min-width : 300px)
and (max-width : 640px) {
.col { float: left;}
.col { float: left;}
.mobile-not {
display:none;
}
}
#media only screen
and (min-width: 768px) {
.col { float: left;}
.col-6-md { width: 50%; }
}
#media only screen
and (min-width : 1224px) {
.col-1 { width: 8.33%; }
.col-2 { width: 16.66%; }
.col-2-sm {width: inherit; }
.col-3 { width: 25%; }
.col-4 { width: 33.33%; }
.col-5 { width: 41.66%; }
.col-6 { width: 50%; }
.col-6-md {
display:block;
width: inherit;
}
.col-7 { width: 58.33%; }
.col-8 { width: 66.66%; }
.col-9 { width: 75%; }
.col-10 { width: 83.33%; }
.col-11 { width: 91.66%; }
.col-12 { width: 100%; }
}
img {
width: 100%;
}
.text-demo {
background-color: #0099ff;
}
.text-prop {
padding-right: 20px;
color:white;
text-align: right;
width:100%;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-6">
<a href="/search/">
<img src="https://lh3.googleusercontent.com/xVYh_uJU1fipLAg85BABZvd5rmSTCg-lSFkZR78jP9lCNxjVRHF8dcIkRE_sGh7ReMWs0xo0azaV-nnCsZ-BVbPBVEjZuVi6uojDNHaDlohDCNM2hGL02nASyMhhdWH5yZ6ZjKF2di8IC6HCkDS-VZ5UBb4eryKcmtbKvpDRm7q-knmu_C9GQx3CsNjQIkZhpmoI6asAlrs_DkJK2hgLN_n-lXFBhLDEQnnYMWR1iYLa3yePtSPVHSzzKOODpNPQqZM9oVtNRizEIysesic__qzrHW0bSmEANsnhutwK--2Cs4jc96isl0XQdKfsqTHzcG_Nc5g2-gIegFHnDWYxsh-KgqLtizc4VaBB2oe1BhUN98pIblCkSVgr88PNSPzeqdF6Dz1fjxCqbD1uvuhfPlhiDmcrmLFyf9fzqYzQtOFLyZuojLohGjivsMYhUkSdghen7XkkdvJx-6lK9baVw4kHXp7M1ZbufApnT8wb1PPBmA8Y1TqkeRQkIfBnEbX5G6VWRNiq0AIOWwkvJSwxGLlwL7Kuh7p77JbTqyn-0w1ydDq80bmFKtvnvnf2AQEvmuTFdgSiFAMWJbYlb5o8_nnuGvATqmCd57DanPW8mOsrULpfaTHi=w468-h379-no">
</a>
</div>
<div class="col-6">
<div class="col-2-sm">
<a href="/search/">
<img src="https://lh3.googleusercontent.com/xVYh_uJU1fipLAg85BABZvd5rmSTCg-lSFkZR78jP9lCNxjVRHF8dcIkRE_sGh7ReMWs0xo0azaV-nnCsZ-BVbPBVEjZuVi6uojDNHaDlohDCNM2hGL02nASyMhhdWH5yZ6ZjKF2di8IC6HCkDS-VZ5UBb4eryKcmtbKvpDRm7q-knmu_C9GQx3CsNjQIkZhpmoI6asAlrs_DkJK2hgLN_n-lXFBhLDEQnnYMWR1iYLa3yePtSPVHSzzKOODpNPQqZM9oVtNRizEIysesic__qzrHW0bSmEANsnhutwK--2Cs4jc96isl0XQdKfsqTHzcG_Nc5g2-gIegFHnDWYxsh-KgqLtizc4VaBB2oe1BhUN98pIblCkSVgr88PNSPzeqdF6Dz1fjxCqbD1uvuhfPlhiDmcrmLFyf9fzqYzQtOFLyZuojLohGjivsMYhUkSdghen7XkkdvJx-6lK9baVw4kHXp7M1ZbufApnT8wb1PPBmA8Y1TqkeRQkIfBnEbX5G6VWRNiq0AIOWwkvJSwxGLlwL7Kuh7p77JbTqyn-0w1ydDq80bmFKtvnvnf2AQEvmuTFdgSiFAMWJbYlb5o8_nnuGvATqmCd57DanPW8mOsrULpfaTHi=w468-h379-no">
</a>
</div>
<div class="col-2-sm mobile-not">
<div class="text-demo">
<div class="text-prop">
<br>
<font size="3.5"> <strong>Wcsho </strong> </font><br>
<font size="6"> <strong>Demo Site </strong><br></font><br>
<font size="3"> SALES: 888-888-1234<br>
SERVICE: 888-888-1234<br>
Custom: 888-888-1234<br>
</font>
<br>
<font size="2">
<a href="/hours-and-directions/">
918 greenville Rd,<br> uk
</a>
</font>
<br><br>
</div>
<br>
</div>
</div>
<br style="clear:both" />
<div class="col-2-sm">
<a href="/search/">
<img src="https://lh3.googleusercontent.com/xVYh_uJU1fipLAg85BABZvd5rmSTCg-lSFkZR78jP9lCNxjVRHF8dcIkRE_sGh7ReMWs0xo0azaV-nnCsZ-BVbPBVEjZuVi6uojDNHaDlohDCNM2hGL02nASyMhhdWH5yZ6ZjKF2di8IC6HCkDS-VZ5UBb4eryKcmtbKvpDRm7q-knmu_C9GQx3CsNjQIkZhpmoI6asAlrs_DkJK2hgLN_n-lXFBhLDEQnnYMWR1iYLa3yePtSPVHSzzKOODpNPQqZM9oVtNRizEIysesic__qzrHW0bSmEANsnhutwK--2Cs4jc96isl0XQdKfsqTHzcG_Nc5g2-gIegFHnDWYxsh-KgqLtizc4VaBB2oe1BhUN98pIblCkSVgr88PNSPzeqdF6Dz1fjxCqbD1uvuhfPlhiDmcrmLFyf9fzqYzQtOFLyZuojLohGjivsMYhUkSdghen7XkkdvJx-6lK9baVw4kHXp7M1ZbufApnT8wb1PPBmA8Y1TqkeRQkIfBnEbX5G6VWRNiq0AIOWwkvJSwxGLlwL7Kuh7p77JbTqyn-0w1ydDq80bmFKtvnvnf2AQEvmuTFdgSiFAMWJbYlb5o8_nnuGvATqmCd57DanPW8mOsrULpfaTHi=w468-h379-no">
</a>
</div>
<div class="col-2-sm">
<a href="/search/">
<img src="https://lh3.googleusercontent.com/xVYh_uJU1fipLAg85BABZvd5rmSTCg-lSFkZR78jP9lCNxjVRHF8dcIkRE_sGh7ReMWs0xo0azaV-nnCsZ-BVbPBVEjZuVi6uojDNHaDlohDCNM2hGL02nASyMhhdWH5yZ6ZjKF2di8IC6HCkDS-VZ5UBb4eryKcmtbKvpDRm7q-knmu_C9GQx3CsNjQIkZhpmoI6asAlrs_DkJK2hgLN_n-lXFBhLDEQnnYMWR1iYLa3yePtSPVHSzzKOODpNPQqZM9oVtNRizEIysesic__qzrHW0bSmEANsnhutwK--2Cs4jc96isl0XQdKfsqTHzcG_Nc5g2-gIegFHnDWYxsh-KgqLtizc4VaBB2oe1BhUN98pIblCkSVgr88PNSPzeqdF6Dz1fjxCqbD1uvuhfPlhiDmcrmLFyf9fzqYzQtOFLyZuojLohGjivsMYhUkSdghen7XkkdvJx-6lK9baVw4kHXp7M1ZbufApnT8wb1PPBmA8Y1TqkeRQkIfBnEbX5G6VWRNiq0AIOWwkvJSwxGLlwL7Kuh7p77JbTqyn-0w1ydDq80bmFKtvnvnf2AQEvmuTFdgSiFAMWJbYlb5o8_nnuGvATqmCd57DanPW8mOsrULpfaTHi=w468-h379-no">
</a>
</div>
</div>
</div>
</div>
</body>
</html>
Any help would be appreciative, I can't figure out how to get everything to fit equally.
Here is an example using flexbox with pure CSS.
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.row{
display: flex;
}
.col{
flex: 1;
margin: 0 1rem;
border: 1px solid black;
}
.square{
background-color: red;
flex: 1;
}
.square:after{
content: '';
display: block;
padding-bottom: 100%;
}
<div class="row">
<div class="col"></div>
<div class="col row">
<div class="col square"></div>
<div class="col square"></div>
<div class="col square"></div>
<div class="col square"></div>
</div>
</div>