Width of element not increasing to max-width - html

In the snippet below, I have assigned a max-width of 400px to the tooltip. It width it has is much less than that. Why doesn't the tooltip have 400px width?
I do not want to explicitly assign it 400px as width because if the content is low, it should have 120px as the width (which is the min-width).
body {
display: flex;
justify-content: center;
height: 100vh;
align-items: center;
}
.select {
position: relative;
height: 30px;
background: black;
color: white;
padding: 10px 20px;
line-height: 30px;
}
.tooltip {
display: none;
}
.tooltip:after {
position: absolute;
bottom: 100%;
left: 100%;
margin-bottom: 30px;
margin-left: -20px;
display: block;
content: attr(title);
background: red;
color: white;
line-height: 16px;
font-size: 14px;
padding: 12px;
min-width: 120px;
max-width: 400px;
}
.tooltip:before {
position: absolute;
bottom: 100%;
left: 100%;
content: '';
height: 0;
width: 0;
border-top: 6px solid red;
border-bottom: 6px solid transparent;
border-left: 9px solid red;
border-right: 9px solid transparent;
margin-left: -20px;
margin-bottom: 21px;
}
.tooltip.active {
display: block;
}
<div class="select">
<div class="tooltip active" title="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempora quam, voluptatem aliquam quos, soluta nostrum repellat unde magni voluptatibus placeat vitae numquam voluptatum ab temporibus id illo. Voluptatem, iusto, incidunt?"></div>
I have a tooltip
</div>

Related

Navigation bar obscures headings

I am creating a resume site, and I ran into a problem that the navigation bar blocks the title, that is, it looks like this https://prnt.sc/ggkfkwSV8KUp, and I need so https://prnt.sc/oX0Hw2G_d_xk.
I tried to indent, but the navbar follows this title and obscures it all the time, no matter how indented I am, how can I fix this? I added code here, (yes, the styles here are not very, not adapted, I know) I removed a lot of code, left only two sections to show, but the fact is that it doesn’t work like mine, more precisely in a small form works like mine, but if you expand it to the whole page, then the navbar does not block the title, but it fits a little, but it can still be shown using this example.
body {
margin: 0;
}
.header {
position: fixed;
width: 100%;
height: 50px;
background: #212121;
z-index: 2;
}
h1 {
margin: 50px;
margin-top: 1px;
float: left;
font-family: cursive;
background-image: linear-gradient(to right, #E55D87 0%, #5FC3E4 51%, #E55D87 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
h2 {
margin-top: 50px;
}
.navbar {
text-transform: uppercase;
line-height: 18px;
height: 50px;
float: right;
}
li {
display:inline-block;
margin:0;
text-transform:uppercase;
}
li:after {
display: block;
content: '';
border-bottom: 1px solid aqua;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
}
li:hover::after {
transform: scaleX(1);
}
.button {
text-decoration: none;
background-image: linear-gradient(to right, #E55D87 0%, #5FC3E4 51%, #E55D87 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-family: cursive;
margin: 10px;
cursor: pointer;
font-size: 20px;
transition: 0.5s;
background-size: 200% auto;
}
.button:hover {
background-position: right center;
}
.my-photo {
position: relative;
border-radius: 50%;
height: 180px;
width: 180px;
padding: 0;
margin-top: 300px;
object-fit: cover;
z-index: -1;
margin-left: 700px;
margin-top: 150px;
}
.h2 {
font-size: 50px;
background: #19CFB1;
background: linear-gradient(to right, #19CFB1 0%, #C978CF 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-align: center;
font-family: cursive;
}
#text {
background: #1338CF;
background: linear-gradient(to right, #1338CF 0%, #CF70AF 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
line-height: 50px;
margin: 0;
font-size: 25px;
text-align: center;
font-family: cursive;
}
.home-image {
position: absolute;
background-size: cover;
background-position: center center;
width: 100%;
height: 100vh;
z-index: -1;
margin-bottom: -10px;
background-image: url("./img/foto-mustang-6-shelby-gt500_01.jpg")
}
.home-image::after {
content: '';
width: 100%;
height: 100%;
position: absolute;
top: 0; left: 0;
background-color: rgba(0,0,0,0.7);
}
blockquote {
text-align: center;
margin: 0;
color: white;
padding: 30px 30px 30px 60px;
font-family: 'Lato', sans-serif;
font-weight: 300;
}
blockquote:before {
content: "\201C";
font-family: Arial;
color: #CBDDE7;
font-size: 50px;
position: absolute;
left: 362px;
top: 596px;
z-index: -1;
}
blockquote p {
font-style: italic;
font-size: 20px;
margin-top: 130px;
}
.about {
padding: 20px 0;
}
#about{
width: 1300px;
height: 687px;
padding: 0 80px;
margin: auto;
}
.title {
position: relative;
text-align: center;
font-size: 40px;
font-weight: 500;
margin-bottom: 26px;
padding-bottom: 20px;
font-family: cursive;
z-index: -1;
}
.title::before {
content: "";
position: absolute;
bottom: 0px;
left: 50%;
width: 180px;
height: 3px;
background: #111;
transform: translateX(-50%);
}
.title::after {
content: "who i am";
font-family: 'Ubuntu', sans-serif;
position: absolute;
bottom: -8px;
left: 50%;
font-size: 20px;
color: crimson;
padding: 0 5px;
background: #fff;
transform: translateX(-50%);
}
.content {
display: flex;
align-items: center;
justify-content: space-between;
}
.image {
height: 500px;
width: 350px;
margin-left: 5px;
margin-top: 50px;
object-fit: cover;
border-radius: 15px;
}
.column-right {
width: 55%;
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 18px;
text-align: justify;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="./img/icon.png" type="image/x-icon">
<link rel="stylesheet" href="./style.css">
<title>CV</title>
</head>
<body>
<header class="header">
<ul class="navbar">
<li>Home</li>
<li>About Me</li>
<li>Portfolio</li>
<li>Contact Me</li>
</ul>
<h1>My CV</h1>
</header>
<section class="home" id="home">
<div class="wrapper">
<div class="home-header home-header-small">
<div class="home-image"></div>
<div class="container">
<div class="content-center">
<div class="profile-image">
<img src="" class="my-photo"/>
</div>
<div class="h2">Lorem ipsum</div>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
<footer>— <cite>Lorem ipsum</cite></footer>
</blockquote>
</div>
</div>
</section>
<section class="about" id="about">
<h2 class="title">About me</h2>
<div class="content">
<img src="" class="image"/>
<div class="column-right">
<div class="text">Lorem ipsum</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit minus impedit maxime, quae soluta quis cumque perferendis! Doloribus quaerat, placeat iste facere, aspernatur ex cum veritatis laudantium, officia, non porro exercitationem incidunt quis dolore? Officia ex accusamus expedita optio, voluptatem minus? In maiores omnis aperiam earum ab molestiae beatae laborum blanditiis incidunt, delectus dolor, id voluptates optio aspernatur aliquam saepe atque labore?</p>
</div>
</div>
</section>
Another options is to use
.header {
position: sticky;
top: 0;
}
/* or, instead*/
.navbar {
position: sticky;
top: 0;
}
body {
margin: 0;
}
.header {
position: sticky;
top: 0px;
width: 100%;
height: 50px;
background: #212121;
z-index: 2;
}
h1 {
margin: 50px;
margin-top: 1px;
float: left;
font-family: cursive;
background-image: linear-gradient(to right, #E55D87 0%, #5FC3E4 51%, #E55D87 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
h2 {
margin-top: 50px;
}
.navbar {
text-transform: uppercase;
line-height: 18px;
height: 50px;
float: right;
}
li {
display:inline-block;
margin:0;
text-transform:uppercase;
}
li:after {
display: block;
content: '';
border-bottom: 1px solid aqua;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
}
li:hover::after {
transform: scaleX(1);
}
.button {
text-decoration: none;
background-image: linear-gradient(to right, #E55D87 0%, #5FC3E4 51%, #E55D87 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-family: cursive;
margin: 10px;
cursor: pointer;
font-size: 20px;
transition: 0.5s;
background-size: 200% auto;
}
.button:hover {
background-position: right center;
}
.my-photo {
position: relative;
border-radius: 50%;
height: 180px;
width: 180px;
padding: 0;
margin-top: 300px;
object-fit: cover;
z-index: -1;
margin-left: 700px;
margin-top: 150px;
}
.h2 {
font-size: 50px;
background: #19CFB1;
background: linear-gradient(to right, #19CFB1 0%, #C978CF 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-align: center;
font-family: cursive;
}
#text {
background: #1338CF;
background: linear-gradient(to right, #1338CF 0%, #CF70AF 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
line-height: 50px;
margin: 0;
font-size: 25px;
text-align: center;
font-family: cursive;
}
.home-image {
position: absolute;
background-size: cover;
background-position: center center;
width: 100%;
height: 100vh;
z-index: -1;
margin-bottom: -10px;
background-image: url("./img/foto-mustang-6-shelby-gt500_01.jpg")
}
.home-image::after {
content: '';
width: 100%;
height: 100%;
position: absolute;
top: 0; left: 0;
background-color: rgba(0,0,0,0.7);
}
blockquote {
text-align: center;
margin: 0;
color: white;
padding: 30px 30px 30px 60px;
font-family: 'Lato', sans-serif;
font-weight: 300;
}
blockquote:before {
content: "\201C";
font-family: Arial;
color: #CBDDE7;
font-size: 50px;
position: absolute;
left: 362px;
top: 596px;
z-index: -1;
}
blockquote p {
font-style: italic;
font-size: 20px;
margin-top: 130px;
}
.about {
padding: 20px 0;
}
#about{
width: 1300px;
height: 687px;
padding: 0 80px;
margin: auto;
}
.title {
position: relative;
text-align: center;
font-size: 40px;
font-weight: 500;
margin-bottom: 26px;
padding-bottom: 20px;
font-family: cursive;
z-index: -1;
}
.title::before {
content: "";
position: absolute;
bottom: 0px;
left: 50%;
width: 180px;
height: 3px;
background: #111;
transform: translateX(-50%);
}
.title::after {
content: "who i am";
font-family: 'Ubuntu', sans-serif;
position: absolute;
bottom: -8px;
left: 50%;
font-size: 20px;
color: crimson;
padding: 0 5px;
background: #fff;
transform: translateX(-50%);
}
.content {
display: flex;
align-items: center;
justify-content: space-between;
}
.image {
height: 500px;
width: 350px;
margin-left: 5px;
margin-top: 50px;
object-fit: cover;
border-radius: 15px;
}
.column-right {
width: 55%;
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 18px;
text-align: justify;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="./img/icon.png" type="image/x-icon">
<link rel="stylesheet" href="./style.css">
<title>CV</title>
</head>
<body>
<header class="header">
<ul class="navbar">
<li>Home</li>
<li>About Me</li>
<li>Portfolio</li>
<li>Contact Me</li>
</ul>
<h1>My CV</h1>
</header>
<section class="home" id="home">
<div class="wrapper">
<div class="home-header home-header-small">
<div class="home-image"></div>
<div class="container">
<div class="content-center">
<div class="profile-image">
<img src="" class="my-photo"/>
</div>
<div class="h2">Lorem ipsum</div>
<p id="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
<footer>— <cite>Lorem ipsum</cite></footer>
</blockquote>
</div>
</div>
</section>
<section class="about" id="about">
<h2 class="title">About me</h2>
<div class="content">
<img src="" class="image"/>
<div class="column-right">
<div class="text">Lorem ipsum</div>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit minus impedit maxime, quae soluta quis cumque perferendis! Doloribus quaerat, placeat iste facere, aspernatur ex cum veritatis laudantium, officia, non porro exercitationem incidunt quis dolore? Officia ex accusamus expedita optio, voluptatem minus? In maiores omnis aperiam earum ab molestiae beatae laborum blanditiis incidunt, delectus dolor, id voluptates optio aspernatur aliquam saepe atque labore?</p>
</div>
</div>
</section>

Placing a transparent div with borders on top of another transparent div with borders

Please see the image below.
contact-image
I want to make a contact container that has a square Contact header. I want the contact header in the middle of the container halfway out of the container. Problem is, both the header and the container have to be transparent and they have borders. The borders of the container cut right through the contact header. I'm having trouble removing the borders from inside the header.
<style>* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-size: 100%;
}
body {
display: flex;
align-items: center;
justify-content: center;
padding-top: 30px;
padding-bottom: 20px;
}
.profile {
width: 480px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
ul {
list-style-type: none;
}
li {
display: inline;
}
.contact {
margin-bottom: 5px;
}
.container {
border: 2px solid gray;
}
.contact {
width: 40%;
margin-top: -23px;
border: 2px solid gray;
}
.header {
display: flex;
align-items: center;
justify-content: center;
}
h2 {
font-size: 25px;
text-align: center;
margin-top: 5px;
margin-bottom: 5px;
}
.container {
height: 380px;
}
.content {
width: 400px;
height: 70%;
margin: 0 auto;
}
.social {
display: flex;
align-items: center;
justify-content: center;
}
</style>
<div class="profile">
<section class="container">
<div class="header">
<div class="contact">
<h2>Contact</h2>
</div>
</div>
<div class="content">
<p class="about">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Recusandae distinctio libero repudiandae consequatur qui, vel ad error animi doloremque magni cupiditate officia officiis et? Vel voluptatem reiciendis placeat cumque officiis!</p>
</div>
<div class="social">
<ul>
<li>Twitter</li>
<li>Behance</li>
<li>Instagram</li>
</ul>
</div>
</section>
</div>
Just use <fieldset> and <legend>.
the legend is a title in a fieldset and the border of a fieldset will not go through the legend. The legend can be aligned with the margin.
fieldset {
border: 2px solid black;
min-height: 50vh;
}
legend {
border: 2px solid black;
margin: 0 auto;
padding: 5px 20px;
}
<fieldset>
<legend>Contact</legend>
</fieldset>
Adapted from another answer, you could try this instead of border-top:
body {
background: url('https://picsum.photos/536/354');
background-size: cover;
}
.header {
width: 240px;
border: 4px solid gray;
height: 50px;
margin: auto;
position: relative;
top: 25px;
padding: 10px;
text-align: center;
}
.box {
width: 350px;
height: 100px;
position: relative;
margin: auto;
border-left: 4px solid gray;
border-right: 4px solid gray;
border-bottom: 4px solid gray;
padding: 20px;
}
.box:after {
content: '';
width: 60px;
height: 4px;
background: gray;
position: absolute;
top: 0px;
left: 0;
}
.box:before {
content: '';
width: 60px;
height: 4px;
background: gray;
position: absolute;
top: 0px;
right: 0;
}
<div class="header">
title
</div>
<div class="box">
content
</div>

How I need to use after style with tailwind?

I'm using tailwind css, but I want to import some cards that I saw in a video. I know that I can use in class the after: attribute by tailwind, but its a waste of time when I already have it on css.
This cards are working perfectly without tailwind, but when I add the tailwind CSS a part of the :after is not working. I tried adding !important to the attributes but it still doesn't work.
How it shows with tailwind:
How it shows without tailwind:
My code:
.container {
position: relative;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
transform: skewY(-10deg);
}
.container .card {
position: relative;
width: 300px;
height: 400px;
background: white;
transition: 0.5s;
}
.container .card:before {
content: "";
position: absolute;
top: -15px;
left: 0;
width: 100%;
height: 15px;
background-color: #ddc700;
transform-origin: bottom;
transform: skewX(45deg);
transition: 0.5s;
}
.container .card:after {
content: "";
position: absolute;
top: -15px;
left: -15px;
width: 15px;
height: 50%;
background-color: #ddc700;
transform-origin: left;
transform: skewY(45deg);
transition: 0.5s;
border-bottom: 200px solid #d9d9d9;
}
.container .card:hover {
transform: translateY(-40px);
}
.container .card .imgBx {
position: relative;
width: 300px;
height: 200px;
background-color: #c6b200;
display: flex;
align-items: center;
flex-direction: column;
}
.container .card .imgBx img {
max-width: 100px;
}
.container .card .imgBx h3 {
position: relative;
color: black;
margin-top: 10px;
}
.container .card .content {
position: relative;
width: 100%;
height: 200px;
padding: 20px;
color: black;
background: white;
text-align: center;
}
.container .card .content:before {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 400px;
background: linear-gradient(transparent, transparent, gray);
transform-origin: bottom;
transform: skewX(45deg);
transition: 0.5s;
z-index: -1;
}
.container .card:hover .content:before {
transform: translateY(40px) skewX(45deg);
filter: blur(5px);
opacity: 0.5;
}
.container .card:nth-child(1) {
z-index: 3;
}
.container .card:nth-child(2) {
z-index: 2;
}
.container .card:nth-child(3) {
z-index: 1;
}
#media (max-width: 414px) {
body {
overflow: auto;
}
.card {
width: 80%;
margin-bottom: 50px;
}
.container {
padding-top: 200px;
position: relative;
left: 15%;
top: 80%;
}
.container .card {
padding-bottom: 40px;
}
.container .card:hover {
transform: translateY(-25px);
}
}
<head>
<!-- Styles -->
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="flex flex-col h-screen bg-black">
<div class="flex justify-center items-center text-center min-h-screen align-middle py-5 mb-3">
<div class="container">
<div class="card">
<div class="imgBx">
<h3>PUMP & DUMP</h3>
<br/>
<img src="https://i.gyazo.com/4f57be20b3be56b44ee2e6f1f13f4bc4.png" alt=""/>
</div>
<div class="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit quidem
cupiditate ullam animi fuga impedit odio dignissimos ab cum?
</div>
</div>
<div class="card">
<div class="imgBx">
<h3>PREVENTAS</h3>
<br/>
<img src="https://i.gyazo.com/4f57be20b3be56b44ee2e6f1f13f4bc4.png" alt=""/>
</div>
<div class="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit quidem
cupiditate ullam animi fuga impedit odio dignissimos ab cum?
</div>
</div>
<div class="card">
<div class="imgBx">
<h3>PASIVOS</h3>
<br/>
<img src="https://i.gyazo.com/4f57be20b3be56b44ee2e6f1f13f4bc4.png" alt=""/>
</div>
<div class="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit quidem
cupiditate ullam animi fuga impedit odio dignissimos ab cum?
</div>
</div>
</div>
</div>
</body>
</html>
Your problem is the height was only 50%
You need to make it like this
.container .card:after {
content: "";
position: absolute;
top: -15px;
left: -15px;
width: 15px;
height: 100%; /*Should change here from 50% to 100%*/
background-color: #ddc700;
transform-origin: left;
transform: skewY(45deg);
transition: 0.5s;
border-bottom: 200px solid #d9d9d9;
}

Unable to create a web layout design

I am unable to create a web layout I am using only HTML and CSS . Kindly help me out here
my code :
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
section {
min-height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: #fddcc356;
}
.container {
width: 90%;
max-width: 600px;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
}
.img_part {
width: 40%;
height: 250px;
background: url(images/hat.jpg) no-repeat center/cover;
border-radius: 8px;
position: relative;
}
.text_part {
width: 50%;
min-height: 550px;
background-color: black;
display: flex;
justify-content: center;
align-items: center;
padding: 30px;
border-radius: 8px;
color: white;
margin-left: -20px;
}
.text_part h1 {
font-size: 40px;
font-weight: lighter;
}
.text_part p {
margin: 20px 0;
line-height: 25px;
font-weight: 500;
}
.text_part a {
text-decoration: none;
color: black;
padding: 20px 30px;
letter-spacing: 2px;
display: inline-block;
text-transform: uppercase;
background-color: white;
position: absolute;
}
.behind_part {
min-width: 25%;
min-height: 100px;
background-color: brown;
position: absolute;
border: 2px solid red;
margin-right: 350px;
margin-top: -350px;
}
<section>
<div class="container">
<div class="img_part"></div>
<div class="text_part">
<div class="content">
<h1>French girl</h1>
<h1>Summer Outfit</h1>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt.
</p>
Learn More
</div>
</div>
<div class="behind_part"></div>
</div>
</section>
My Output :
The actual output:
Problem: The main problem here is that I cannot move the brown container behind the image as it completely covers my image . I want to show brown container behind the image such that it does not cover the face of the image.
Although I manage to do the task 90% how can I tackle this problem.
The z-index property in CSS specifies how elements overlap each other.
The z-index CSS property sets the z-order of a positioned element and its descendants or flex items. Overlapping elements with a larger z-index cover those with a smaller one.
MDN Docs
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
section {
min-height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: #fddcc356;
}
.container {
width: 90%;
max-width: 600px;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
}
.img_part {
width: 40%;
height: 250px;
background: url(https://via.placeholder.com/200) no-repeat center/cover;
border-radius: 8px;
position: relative;
}
.text_part {
width: 50%;
min-height: 550px;
background-color: black;
display: flex;
justify-content: center;
align-items: center;
padding: 30px;
border-radius: 8px;
color: white;
margin-left: -20px;
}
.text_part h1 {
font-size: 40px;
font-weight: lighter;
}
.text_part p {
margin: 20px 0;
line-height: 25px;
font-weight: 500;
}
.text_part a {
text-decoration: none;
color: black;
padding: 20px 30px;
letter-spacing: 2px;
display: inline-block;
text-transform: uppercase;
background-color: white;
position: absolute;
}
.behind_part {
min-width: 25%;
min-height: 150px;
background-color: brown;
position: absolute;
border: 2px solid red;
margin-right: 350px;
margin-top: -350px;
z-index: -999;
}
<section>
<div class="container">
<div class="img_part"></div>
<div class="text_part">
<div class="content">
<h1>French girl</h1>
<h1>Summer Outfit</h1>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt.
</p>
Learn More
</div>
</div>
<div class="behind_part"></div>
</div>
</section>
Adding z-index: -999; to the image will make it move to the back.

How to use skew property in the middle of container to top and bottom

I used the code from my snippet to have the shapes in the middle as you can see if you run the snippet, except the last box. However, I dont want the white spacing between the boxes but am struggling to do that
.image-container {
position: relative;
width: 100%;
height: 331px;
padding: 40px 20px;
box-sizing: border-box;
text-align: center;
display: flex;
flex-flow: wrap column;
align-items: center;
justify-content: center;
}
.image-container:before {
content: '';
position: absolute;
z-index: -4;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.image-container.image-container-col-2 .image-container-split:nth-child(odd) {
left: 0;
right: 50%;
}
.image-container.image-container-col-2 .image-container-split:nth-child(even) {
left: 50%;
right: 0;
}
.image-container-split {
position: absolute;
z-index: -3;
top: 0;
bottom: 0;
box-sizing: border-box;
border: 20px solid transparent;
border-bottom-color: #fff;
padding-bottom: 20px;
display: flex;
flex-direction: wrap column;
align-items: center;
justify-content: center;
}
.image-container-split:first-child {
border-left: none;
padding-left: 20px;
}
.image-container-split:last-child {
border-right: none;
padding-right: 20px;
}
.image-container-split:before {
content: '';
position: absolute;
z-index: -1;
top: -20px;
border: 10px solid #fff;
border-bottom-color: transparent;
}
.image-container-split:nth-child(odd):before {
right: -20px;
border-left-color: transparent;
}
.image-container-split:nth-child(even):before {
left: -20px;
border-right-color: transparent;
}
.image-container-split:after {
content: '';
position: absolute;
z-index: -3;
top: -20px;
left: 0;
right: 0;
bottom: -20px;
opacity: 0.5;
border: 20px solid transparent;
border-bottom-color: #fff;
}
.image-container-split:first-child:after {
border-left: none;
}
.image-container-split:last-child:after {
border-right: none;
}
.image-container-split:nth-child(odd):after {
background-color: red;
right: -20px;
}
.image-container-split:nth-child(even):after {
background-color: red;
left: -20px;
}
.new_container{
background: blue;
}
.blue{
background-color: blue;
}
<section id="latest_news">
<div class="skewing_mixin">
<div class="image-container image-container-col-2">
<div class="container">
<!-- content goes here -->
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ex aspernatur praesentium iste ratione nesciunt consectetur animi, temporibus, commodi quibusdam, nemo assumenda provident nam vel? Necessitatibus sint sit illum atque.
</div>
<div class="image-container-split-container">
<div class="image-container-split">
</div>
<div class="image-container-split">
</div>
</div>
</div>
</div>
<div class="skewing_mixin">
<div class="image-container image-container-col-2">
<div class="container">
<!-- content goes here -->
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione animi expedita, fugiat deleniti sit quos in accusamus laboriosam! Nulla rerum vero sunt accusamus. Suscipit nesciunt reiciendis est repudiandae sunt modi.
</div>
<div class="image-container-split-container">
<div class="image-container-split blue">
</div>
<div class="image-container-split blue">
</div>
</div>
</div>
</div>
<div class="new_container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque corrupti voluptatibus sapiente optio modi veritatis eveniet corporis deleniti aspernatur dolores atque doloribus alias, laborum officiis quod consectetur! Possimus magni, officiis.
</div>
</section>
Hope you can help me achieve that with a better technique.
Thanks in advance
For that you shoud use another simple technique like this one
DEMO HERE
CSS
.first,
.second,
.third {
position: relative;
display: block;
height: 100px;
padding: 20px;
}
.first {
background: red;
}
.first:after {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(255, 0, 0, 0);
border-top-color: red;
border-width: 30px;
margin-left: -30px;
z-index: 2;
}
.second {
background: blue;
}
.second:after {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(0, 0, 255, 0);
border-top-color: blue;
border-width: 30px;
margin-left: -30px;
z-index: 2;
}
.third {
background: yellow;
}
HTML
<div class="first">
sdfsdfsdfsdfsdf
</div>
<div class="second">
sdfsdfsdfsdfsfs
</div>
<div class="third">
sdfsdfsdfsdfs
</div>
just add margin-bottom: -20px; to .image-container to bring them closer
.image-container {
position: relative;
width: 100%;
height: 331px;
padding: 40px 20px;
box-sizing: border-box;
text-align: center;
display: flex;
flex-flow: wrap column;
align-items: center;
justify-content: center;
margin-bottom: -20px;
}
.image-container:before {
content: '';
position: absolute;
z-index: -4;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.image-container.image-container-col-2 .image-container-split:nth-child(odd) {
left: 0;
right: 50%;
}
.image-container.image-container-col-2 .image-container-split:nth-child(even) {
left: 50%;
right: 0;
}
.image-container-split {
position: absolute;
z-index: -3;
top: 0;
bottom: 0;
box-sizing: border-box;
border: 20px solid transparent;
border-bottom-color: #fff;
padding-bottom: 20px;
display: flex;
flex-direction: wrap column;
align-items: center;
justify-content: center;
}
.image-container-split:first-child {
border-left: none;
padding-left: 20px;
}
.image-container-split:last-child {
border-right: none;
padding-right: 20px;
}
.image-container-split:before {
content: '';
position: absolute;
z-index: -1;
top: -20px;
border: 10px solid #fff;
border-bottom-color: transparent;
}
.image-container-split:nth-child(odd):before {
right: -20px;
border-left-color: transparent;
}
.image-container-split:nth-child(even):before {
left: -20px;
border-right-color: transparent;
}
.image-container-split:after {
content: '';
position: absolute;
z-index: -3;
top: -20px;
left: 0;
right: 0;
bottom: -20px;
opacity: 0.5;
border: 20px solid transparent;
border-bottom-color: #fff;
}
.image-container-split:first-child:after {
border-left: none;
}
.image-container-split:last-child:after {
border-right: none;
}
.image-container-split:nth-child(odd):after {
background-color: red;
right: -20px;
}
.image-container-split:nth-child(even):after {
background-color: red;
left: -20px;
}
.new_container{
background: blue;
}
.blue{
background-color: blue;
}
<section id="latest_news">
<div class="skewing_mixin">
<div class="image-container image-container-col-2">
<div class="container">
<!-- content goes here -->
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ex aspernatur praesentium iste ratione nesciunt consectetur animi, temporibus, commodi quibusdam, nemo assumenda provident nam vel? Necessitatibus sint sit illum atque.
</div>
<div class="image-container-split-container">
<div class="image-container-split">
</div>
<div class="image-container-split">
</div>
</div>
</div>
</div>
<div class="skewing_mixin">
<div class="image-container image-container-col-2">
<div class="container">
<!-- content goes here -->
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione animi expedita, fugiat deleniti sit quos in accusamus laboriosam! Nulla rerum vero sunt accusamus. Suscipit nesciunt reiciendis est repudiandae sunt modi.
</div>
<div class="image-container-split-container">
<div class="image-container-split blue">
</div>
<div class="image-container-split blue">
</div>
</div>
</div>
</div>
<div class="new_container">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque corrupti voluptatibus sapiente optio modi veritatis eveniet corporis deleniti aspernatur dolores atque doloribus alias, laborum officiis quod consectetur! Possimus magni, officiis.
</div>
</section>