How to overlap elements in CSS? - html

I have this stepper attached as an example in fiddle.
.stepper-wrapper {
font-family: Arial;
margin-top: 50px;
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}
.stepper-item {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
}
.stepper-item::before {
position: absolute;
content: "";
border-bottom: 2px solid #ccc;
width: 100%;
top: 9px;
left: -50%;
z-index: 2;
}
.stepper-item::after {
position: absolute;
content: "";
border-bottom: 2px solid #ccc;
width: 100%;
top: 9px;
left: 50%;
z-index: 2;
}
.stepper-item .step-counter {
position: relative;
z-index: 5;
display: flex;
justify-content: center;
align-items: center;
width: 18px;
height: 18px;
border-radius: 50%;
background: #ccc;
margin-bottom: 12px;
}
.stepper-item.active {
font-weight: bold;
}
.stepper-item.active .step-counter {
background-color: red;
border: 1px solid red;
width: 15px;
height: 15px;
background-clip: content-box;
padding: 3px;
top: -2px;
margin-bottom: 8px;
z-index: 3;
}
.stepper-item.completed .step-counter {
background-color: red;
}
.stepper-item.completed::after {
position: absolute;
content: "";
border-bottom: 2px solid red;
width: 100%;
top: 9px;
left: 50%;
z-index: 3;
}
.stepper-item:first-child::before {
content: none;
}
.stepper-item:last-child::after {
content: none;
}
<div class="stepper-wrapper">
<div class="stepper-item completed">
<div class="step-counter"></div>
<div class="step-name">First</div>
</div>
<div class="stepper-item completed">
<div class="step-counter"></div>
<div class="step-name">Second</div>
</div>
<div class="stepper-item active">
<div class="step-counter"></div>
<div class="step-name">Third</div>
</div>
<div class="stepper-item">
<div class="step-counter"></div>
<div class="step-name">Forth</div>
</div>
</div>
But I don't know how to overlap this active element so that these left and right lines go until the first (outer) circle.
This part...
How to make this in CSS?
It should be something like this.

Our main goal here is to cover-up the space between the actual element and its border.
The space can be filled by an inset box-shadow.
It will hide all the content under it; just give the right amount of spread with zero blur :)
Just add this snippet to the element:
box-shadow: 0 0 0 3px white inset;
Here's the edited snippet
.stepper-wrapper {
font-family: Arial;
margin-top: 50px;
display: flex;
justify-content: space-between;
margin-bottom: 20px;
}
.stepper-item {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
}
.stepper-item::before {
position: absolute;
content: "";
border-bottom: 2px solid #ccc;
width: 100%;
top: 9px;
left: -50%;
z-index: 2;
}
.stepper-item::after {
position: absolute;
content: "";
border-bottom: 2px solid #ccc;
width: 100%;
top: 9px;
left: 50%;
z-index: 2;
}
.stepper-item .step-counter {
position: relative;
z-index: 5;
display: flex;
justify-content: center;
align-items: center;
width: 18px;
height: 18px;
border-radius: 50%;
background: #ccc;
margin-bottom: 12px;
}
.stepper-item.active {
font-weight: bold;
}
.stepper-item.active .step-counter {
background-color: red;
border: 1px solid red;
width: 15px;
height: 15px;
background-clip: content-box;
/* Here it is */
box-shadow: 0 0 0 3px white inset;
padding: 3px;
top: -2px;
margin-bottom: 8px;
z-index: 3;
}
.stepper-item.completed .step-counter {
background-color: red;
}
.stepper-item.completed::after {
position: absolute;
content: "";
border-bottom: 2px solid red;
width: 100%;
top: 9px;
left: 50%;
z-index: 3;
}
.stepper-item:first-child::before {
content: none;
}
.stepper-item:last-child::after {
content: none;
}
<div class="stepper-wrapper">
<div class="stepper-item completed">
<div class="step-counter"></div>
<div class="step-name">First</div>
</div>
<div class="stepper-item completed">
<div class="step-counter"></div>
<div class="step-name">Second</div>
</div>
<div class="stepper-item active">
<div class="step-counter"></div>
<div class="step-name">Third</div>
</div>
<div class="stepper-item">
<div class="step-counter"></div>
<div class="step-name">Forth</div>
</div>
</div>

I found this one for your problem, I hope this helps you.
.stepper-item.active .step-counter::after {
position: absolute;
content: "";
width: 15px;
height: 15px;
border-radius: 50%;
border: 3px solid white;
}

Related

Why does browser zoom cause line artifacts in my web css html element

In a css/html element on a webpage I've made, if a user zooms in or out on their browser, artifacts emerge showing a line. Here is a code pen of the issue. Zoom in or out on your browser to see the red line at top emerge like below:
I've read that these problems can emerge because a browser can set the zoom to 1.5x, thus creating rounding issues for pixels. See slack post here. But I'm not sure what the appropriate fix should be. In my case I want the triangles at each end of my rectangle element which I create via css styling. Besides recreating the graphic via svg, is there any good tricks?
Here is the html/css in codepen:
#root {
display: block;
width: 100%;
height: 100%;
background-color: lightgrey;
padding: 24px;
max-width: 400px;
float: center;
position: relative;
}
#gridRoot {
display: flex;
flex-flow: column wrap;
top: 50%;
left: 50%;
align-content: center;
}
#LegendContainer {
box-sizing: border-box;
display: flex;
flex-flow: row nowrap;
width: 100%;
align-items: center;
justify-content: space-between;
}
#container {
background-color: grey;
postion: relative;
height: 120px;
justify-content: center;
left: calc(50% - 60px);
text-align: center;
top: calc(50% - 60px);
}
#circle {
transform: rotate(7.39deg);
}
#jss {
display: flex;
position: absolute;
background: red;
top: 40px;
width: 110px;
opacity: 80%;
height: 20px;
}
#jss::before {
left: 0;
width: 0;
bottom: 0;
height: 0;
content: '';
position: absolute;
transform: rotate(180deg);
border-top: 10px solid white;
border-left: 10px solid #00007f;
border-bottom: 10px solid white;
}
#jss::after {
right: 0;
width: 0;
bottom: 0;
height: 0;
content: '';
position: absolute;
border-top: 10px solid white;
border-left: 10px solid #7f0000;
border-bottom: 10px solid white;
}
<div id="root">
<div id="gridRoot">
<div id="LegendContainer">
<div id="container">
<div id="circle">
</div>
<div id="jss">
</div>
</div>
</div>
</div>
</div>
The ::before and ::after elements seemed to be causing the issue. Solution;
body {
margin: 0;
}
#container {
background-color: grey;
position: relative;
display: flex;
height: 120px;
justify-content: center;
text-align: center;
}
#jss {
display: flex;
position: absolute;
top: 40px;
width: 110px;
opacity: 80%;
height: 20px;
}
#jss-internal {
background: red;
width: 100%;
}
#jss-before {
content: '';
transform: rotate(180deg);
border-top: 10px solid white;
border-left: 10px solid #00007f;
border-bottom: 10px solid white;
}
#jss-after {
border-top: 10px solid white;
border-left: 10px solid #7f0000;
border-bottom: 10px solid white;
}
<div id="root">
<div id="LegendContainer">
<div id="container">
<div id="circle">
</div>
<div id="jss">
<div id="jss-before">
</div>
<div id="jss-internal">
</div>
<div id="jss-after">
</div>
</div>
</div>
</div>
</div>

How to make a speech bubble with CSS?

Is it possible to style the following HTML structure to the image shown below with CSS only?
<div class="xyz-dialog">
<div class="title"><span> Tip Title</span></div>
<div class="body"> <span>Description</span></div>
</div>
Required design:
You can do it as below if we can add a container div in the HTML:
.container{
background: gray;
padding: 16px 10px;
width:max-content;
}
.xyz-dialog {
background: white;
padding: 1rem;
border-radius: 8px;
position: relative;
width: 300px;
}
.xyz-dialog::after {
content: "";
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid white;
position: absolute;
top: 100%;
}
.body {
margin-top:8px;
color: gray;
font-size: 15px
}
<div class= "container">
<div class="xyz-dialog">
<div class="title"><span> Tip Title</span></div>
<div class="body"> <span>Description</span></div>
</div>
You can do it as below if we cannot touch the HTML structure:
.xyz-dialog {
padding: 1rem;
border-radius: 8px;
position: relative;
width: 300px;
}
.xyz-dialog::after {
content: "";
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid white;
position: absolute;
top: calc(100% -1rem);
left: 2rem;
}
.xyz-dialog::before {
content: "";
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: gray;
z-index: -1;
}
.title {
padding: 1rem;
background: white;
border-radius: 10px 10px 0 0;
margin: 0 0 -5px 0;
}
.body {
color: gray;
font-size: 15px;
background: white;
margin: 0;
padding: 1rem;
border-radius: 0 0 10px 10px;
}
<div class="xyz-dialog">
<div class="title"><span> Tip Title</span></div>
<div class="body"> <span>Description</span></div>
</div>
You can use after and border.
.xyz-dialog::after{
content: "";
border-top: 12px solid #f1f1f1;
border-right: 8px solid transparent;
border-left: 8px solid transparent;
position: absolute;
bottom: -12px;
left: 4%;
}
.xyz-dialog{
width: 50%;
background: #f1f1f1;
border-radius: 0.3em;
padding: 5px 30px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
box-sizing: border-box;
flex-direction: column;
}
<div class="xyz-dialog">
<div class="title"><span> Tip Title</span></div>
<div class="body"> <span>Description</span></div>
</div>
Little late. Two Boxes. For the small noise you use the css pseudo class after.
body {
background-color: #999;
}
.wrapper {
padding:20px;
}
h3 {
margin:0;
color: #000;
}
.bubble {
position: relative;
background: white;
color: #999;
font-family: Arial;
font-size: 16px;
text-align: left;
width: 250px;
height: 120px;
border-radius: 10px;
padding: 0px;
}
.bubble:after {
content: '';
position: absolute;
display: block;
width: 0;
z-index: 1;
border-style: solid;
border-width: 0 20px 20px 0;
border-color: transparent #fff transparent transparent;
bottom: -16px;
left: 17%;
margin-left: -10px;
}
<div class="bubble">
<div class="wrapper">
<h3>title</h3>
<div>content</div>
</div>
</div>

Aligning a div created using :before & :after horizontally to other elements

I am using :before to create a black circle (which should display white text exactly centered within, can't work out why it isn't white) and :after to display a dashed line (as seen). I'd like the black circle (with text inside it) to sit horizontally level with the input but I've been having issues with it as it also creates a big gap between it & the after dashed line. I've played around margin but I don't want to push elements above too far away.
.progress-container {
display: flex;
position: relative;
}
.progress-indicator {
position: relative;
display: inline-block;
margin-bottom: 40px;
color: #fff;
}
.progress-indicator::before {
content: "";
width: 22px;
height: 22px;
background: #000;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
}
.progress-indicator::after {
content: "";
height: 85px;
border: 2px dashed #a9b4b8;
position: absolute;
left: 50%;
top: 49px;
transform: translateX(-50%);
margin-bottom: 10px;
}
.input-container {
display: flex;
align-items: center;
}
.input-wrapper {
border: 1px solid #ced4da;
border-radius: 2px;
overflow-y: hidden;
padding: 0.375rem 1.75rem 0.375rem 0.75rem;
margin-left: 30px;
}
<div class=progress-container>
<div class="progress-indicator">1</div>
<div class="input-container">
<div class="input-wrapper">
<div>Input</div>
</div>
</div>
</div>
Caution: you have a typo in your .progess-container selector correct: .progress-container
Edited your CSS:
.progress-container {
display: flex;
flex-direction: row;
align-items: center;
position: relative;
}
.progress-indicator {
position: relative;
display: inline-block;
color: #fff;
}
.progress-indicator::before {
content: "";
width: 22px;
height: 22px;
background: #000;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
z-index: -1;
}
.progress-indicator::after {
content: "";
height: 85px;
border: 2px dashed #a9b4b8;
position: absolute;
left: 50%;
transform: translateX(-50%);
margin-bottom: 10px;
z-index: -2;
}
.input-container {
display: flex;
align-items: center;
}
.input-wrapper {
border: 1px solid #ced4da;
border-radius: 2px;
overflow-y: hidden;
padding: 0.375rem 1.75rem 0.375rem 0.75rem;
margin-left: 30px;
}
<div class=progress-container>
<div class="progress-indicator">1</div>
<div class="input-container">
<div class="input-wrapper">
<div>Input</div>
</div>
</div>
</div>

Adding pseudo-element between two elements

I would like to insert a pseudo-element between two elements, in e.g.:
.general {
padding: 20px;
border: 1px solid #4a4a4a;
}
.left-subtitle {
float: left;
padding-right: 5px;
background-color: yellow;
}
.right-subtitle {
float: right;
padding-left: 5px;
background-color: red;
position: relative;
}
.right-subtitle:after {
content: '';
width: 100%;
height: 2px;
left: -100%;
bottom: 0;
background-color: blue;
position: absolute;
}
<div class="general">
<h3 class="title">Foo</h3>
<div class="subtitle">
<div class="left-subtitle">Text1</div>
<div class="right-subtitle">9.00 €</div>
</div>
</div>
How can I get the blue ::after to get the full width and being fully between yellow and red elements?
I tried to use display: flex; and justify-content: space-between;
.general {
padding: 20px;
border: 1px solid #4a4a4a;
}
.subtitle {
display: flex;
justify-content: space-between;
position: relative;
}
.subtitle:after {
content: '';
width: 80%;
left: 50%;
transform: translateX(-50%);
height: 2px;
background-color: blue;
position: absolute;
bottom: 0;
}
.left-subtitle {
padding-right: 5px;
background-color: yellow;
}
.right-subtitle {
padding-left: 5px;
background-color: red;
}
<div class="general">
<h3 class="title">Foo</h3>
<div class="subtitle">
<div class="left-subtitle">Text1 is longer, so doesn't work</div>
<div class="right-subtitle">9.00 €</div>
</div>
</div>
Can I achieve this without adding any js files? (I could add them, but it would be better without adding them)
Use flexbox like so:
.general {
padding: 20px;
border: 1px solid #4a4a4a;
}
.subtitle {
display: flex;
justify-content: space-between;
}
.left-subtitle {
padding-right: 5px;
display: flex;
flex: 1;
}
.right-subtitle {
padding-left: 5px;
position: relative;
}
.left-subtitle:after {
content: '';
flex: 1;
border-bottom: 1px solid blue;
}
<div class="general">
<h3 class="title">Foo</h3>
<div class="subtitle">
<div class="left-subtitle">Text1</div>
<div class="right-subtitle">9.00 €</div>
</div>
</div>

How can I skew the middle part of my div box

I am using skew in order to achieve the same design as the one in the photo but I could only get it right for the top part.
How can I do something like this:
you can also see on my codepen here
section#products {
background-image: url("https://www.oceana-residence.com/wp-content/uploads/2016/09/3-min-2.jpg");
background-size: cover;
background-position: top center;
background-repeat: no-repeat;
color: white;
position: relative;
h3 {
font-family: 'Titillium Web';
line-height: 1.2;
font-weight: bold;
font-size: 28px;
text-transform: uppercase;
}
div.products_box {
overflow: auto;
width: 100%;
&>div {
opacity: 0.8;
max-width: 50%;
width: 100%;
height: 450px;
display: flex;
}
.box {
width: 100%;
display: flex;
align-items: center;
.flex {
max-width: 420px;
}
}
.products_left {
background: #2b2b2b;
float: left;
text-align: right;
.fa {
font-size: 100px;
}
.box {
justify-content: flex-end;
padding-right: 50px;
}
.content {}
.left_box {
padding-left: 40px;
}
}
.products_right {
float: right;
background: #d27473;
.box {
justify-content: inital;
padding-left: 50px;
}
.flex {
padding-right: 40px;
}
.fa {
font-size: 170px;
}
}
}
}
.anchor_top {
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 10px solid white;
position: absolute;
left: 49.2%;
top: 0px;
z-index: 1;
}
.anchor_bottom_left {
width: 0;
height: 0;
border-left: 15px solid transparent;
/*border-right: 15px solid transparent;*/
border-top: 10px solid grey;
position: absolute;
left: 49.2%;
bootom: 0px;
z-index: 1;
}
.anchor_bottom_right {
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 10px solid green;
position: absolute;
left: 49.2%;
bootom: 0px;
z-index: 1;
}
<section id="products">
<div class="anchor_top"></div>
<div class="products_box">
<div class="products_left">
<div class="box">
<div class="content flex">
</div>
<div class="left_box">
<div class="flex">
<i class="fa fa-cogs" aria-hidden="true"></i>
</div>
</div>
</div>
</div>
<div class="products_right">
<div class="box">
<div class="flex">
<i class="fa fa-mobile" aria-hidden="true"></i>
</div>
</div>
</div>
</div>
<div class="anchor_bottom_left"></div>
<div class="anchor_bottom_right"></div>
</section>
You can achieve this using :before and :after pseudo-elements.
You can have a container element <div class="image-container image-container-col-2"> and multiple children <div class="image-container-split">.
.image-container-col-2 was added in order to mark that the container will be split in two. Therefore this solution can be adapted to more columns. Or even more, use existing CSS libraries like Bootstrap own column system and adapt that.
The following code is long and, if you are using SCSS for example, you can easily parameterize this in order to be more readable.
SOLUTION 1: content on multiple columns but not on main container
p {
font-size: 1.1em;
font-family: Arial;
color: #fff;
}
.image-container {
position: relative;
width: 500px;
height: 331px;
}
.image-container.image-container-col-2 .image-container-split {
width: 50%;
}
.image-container:before {
content: '';
position: absolute;
z-index: -2;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: url(http://az616578.vo.msecnd.net/files/2016/04/09/6359580807140768861266757027_Never-Study-Hard-The-Art-of-Studying-Smart.jpg);
background-repeat: none;
background-size: cover;
}
.image-container-split {
position: relative;
height: 100%;
float: left;
box-sizing: border-box;
border: 20px solid transparent;
border-bottom-color: #fff;
text-align: center;
/* Flexbox - use this to align items inside your container */
display: flex;
justify-content: center;
align-items: center;
flex-flow: wrap column;
}
.image-container-split:first-child {
border-left: none;
}
.image-container-split:last-child {
border-right: none;
}
.image-container-split:nth-child(odd) {
padding-left: 20px;
}
.image-container-split:nth-child(even) {
padding-right: 20px;
}
.image-container-split:after {
content: '';
position: absolute;
top: -20px;
border: 10px solid #fff;
border-bottom-color: transparent;
}
.image-container-split:nth-child(odd):after {
right: -20px;
border-left-color: transparent;
}
.image-container-split:nth-child(even):after {
left: -20px;
border-right-color: transparent;
}
.image-container-split:before {
content: '';
position: absolute;
z-index: -1;
top: -20px;
right: 0;
left: 0;
bottom: -20px;
border: 20px solid transparent;
border-bottom-color: #fff;
opacity: 0.5;
}
.image-container-split:first-child:before {
border-left: none;
}
.image-container-split:last-child:before {
border-right: none;
}
.image-container-split:nth-child(odd):before {
background-color: red;
right: -20px;
}
.image-container-split:nth-child(even):before {
background-color: blue;
left: -20px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div class="image-container image-container-col-2">
<div class="image-container-split">
<p>This is some content and some more and more and more and more </p>
<p>This is some content</p>
<p>This is some content</p>
</div>
<div class="image-container-split">
<p>This is some content and some more and more and more and more </p>
<p>This is some content</p>
<p>This is some content</p>
</div>
</div>
</body>
</html>
SOLUTION 2: content on multiple columns as well as on main container
Content is placed on main container and on separate two columns (notice the smileys).
p {
font-size: 1.1em;
font-family: Arial;
color: #fff;
}
.image-container-split p {
font-size: 3em;
}
.image-container {
position: relative;
width: 500px;
height: 331px;
padding: 40px 20px;
box-sizing: border-box;
text-align: center;
/* Flexbox - use this to align content */
display: flex;
flex-flow: wrap column;
align-items: center;
justify-content: center;
}
.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:before {
content: '';
position: absolute;
z-index: -4;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: url(http://az616578.vo.msecnd.net/files/2016/04/09/6359580807140768861266757027_Never-Study-Hard-The-Art-of-Studying-Smart.jpg);
background-repeat: none;
background-size: cover;
}
.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;
/* Flexbox - use this to align content */
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: blue;
left: -20px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div class="image-container image-container-col-2">
<p>This is some content and some more and more and more and more </p>
<p>This is some content</p>
<p>This is some content</p>
<div class="image-container-split-container">
<div class="image-container-split">
<p>☺</p>
</div>
<div class="image-container-split">
<p>☺</p>
</div>
</div>
</div>
</body>
</html>
Container with triangles only
If there needs to be container with some triangles then the following can be achieved:
The size of the image is 500 x 331.
:before - is creating the top triangle
:after + background image - is creating the bottom triangle
.image-container has a smaller height than the image in order to use that remaining part to be added to the bottom triangle
p {
font-size: 1.1em;
font-family: Arial;
color: #fff;
}
.image-container-split p {
font-size: 3em;
}
.image-container {
position: relative;
width: 500px;
height: 311px;
padding: 20px;
box-sizing: border-box;
text-align: center;
background-image: url(http://az616578.vo.msecnd.net/files/2016/04/09/6359580807140768861266757027_Never-Study-Hard-The-Art-of-Studying-Smart.jpg);
background-repeat: no-repeat;
background-size: 500px 331px;
/* Flexbox - use this to align content */
display: flex;
flex-flow: wrap column;
align-items: center;
justify-content: center;
}
.image-container:before {
content: '';
position: absolute;
top: 0;
border: 20px solid transparent;
border-top-color: #fff;
}
.image-container:after {
content: '';
left: 50%;
transform: translateX(-20px);
bottom: -40px;
position: absolute;
border: 20px solid #fff;
border-top: 20px solid transparent;
background-image: url(http://az616578.vo.msecnd.net/files/2016/04/09/6359580807140768861266757027_Never-Study-Hard-The-Art-of-Studying-Smart.jpg);
background-size: 500px 331px;
background-repeat: no-repeat;
background-position: center bottom;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div class="image-container">
<p>This is some content and some more and more and more and more </p>
<p>This is some content</p>
<p>This is some content</p>
</div>
</body>
</html>
Just few changes, complete your goal:
.anchor_top {
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 10px solid white;
position: absolute;
left: 48.9%; //change here
top: 0px;
z-index: 1;
}
For bottom part :
.anchor_bottom_left {
width: 0;
height: 0;
border-left: 15px solid transparent;
border-top: 10px solid grey;
position: absolute;
left: 48.9%; //change here
z-index: 1;
}
.anchor_bottom_right {
width: 0;
height: 0;
border-right: 15px solid transparent;
border-top: 10px solid #d98d8e;
position: absolute;
left: 50%; //change here and remove border-left
z-index: 1;
}
One option would be to work with pseudo-classes + transform:skewX.
/* Using pseudo-classes + transform skewX */
.products_box:before,
.products_box:after {
content: '';
display: block;
width: 50%;
position: absolute;
bottom: 0;
height: 15px;
background: white;
transform: skewX(50deg);
z-index: 2;
}
.products_box:before {
left: -10px;
}
.products_box:after {
right: -10px;
transform: skewX(-50deg);
}
See full snippet below.
section#products {
background-image: url("https://www.oceana-residence.com/wp-content/uploads/2016/09/3-min-2.jpg");
background-size: cover;
background-position: top center;
background-repeat: no-repeat;
color: white;
position: relative;
}
section#products h3 {
font-family: 'Titillium Web';
line-height: 1.2;
font-weight: bold;
font-size: 28px;
text-transform: uppercase;
}
section#products div.products_box {
overflow: auto;
width: 100%;
}
section#products div.products_box > div {
opacity: 0.8;
max-width: 50%;
width: 100%;
height: 450px;
display: flex;
}
section#products div.products_box .box {
width: 100%;
display: flex;
align-items: center;
}
section#products div.products_box .box .flex {
max-width: 420px;
}
section#products div.products_box .products_left {
background: #2b2b2b;
float: left;
text-align: right;
}
section#products div.products_box .products_left .fa {
font-size: 100px;
}
section#products div.products_box .products_left .box {
justify-content: flex-end;
padding-right: 50px;
}
section#products div.products_box .products_left .left_box {
padding-left: 40px;
}
section#products div.products_box .products_right {
float: right;
background: #d27473;
}
section#products div.products_box .products_right .box {
justify-content: inital;
padding-left: 50px;
}
section#products div.products_box .products_right .flex {
padding-right: 40px;
}
section#products div.products_box .products_right .fa {
font-size: 170px;
}
.anchor_top {
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 10px solid white;
position: absolute;
left: 49.2%;
top: 0px;
z-index: 1;
}
/*
.anchor_bottom_left{
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 10px solid grey;
position: absolute;
left: 49.2%;
bootom: 0px;
z-index: 1;
}
.anchor_bottom_right{
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 10px solid green;
position: absolute;
left: 49.2%;
bootom: 0px;
z-index: 1;
}
*/
/* Using pseudo-classes + transform skewX */
.products_box:before,
.products_box:after {
content: '';
display: block;
width: 50%;
position: absolute;
bottom: 0;
height: 15px;
background: white;
transform: skewX(50deg);
z-index: 2;
}
.products_box:before {
left: -10px;
}
.products_box:after {
right: -10px;
transform: skewX(-50deg);
}
<section id="products">
<div class="anchor_top"></div>
<div class="products_box">
<div class="products_left">
<div class="box">
<div class="content flex">
<section id="black-studio-tinymce-10" class="widget-1 widget-first widget-last widget-odd widget widget_black_studio_tinymce"><div class="textwidget"><h3>Importance of Business</h3>
<h3>Intelligence Technology</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris congue nisi eget justo rutrum, ut pellentesque nulla posuere. Etiam vitae fringilla massa. Aenean sit amet tellus ex.</p>
</div></section> </div>
<div class="left_box">
<div class="flex">
<i class="fa fa-cogs" aria-hidden="true"></i>
</div>
</div>
</div>
</div>
<div class="products_right">
<!-- about_widget here -->
<div class="box">
<div class="flex">
<i class="fa fa-mobile" aria-hidden="true"></i>
</div>
<div class="content flex">
<section id="black-studio-tinymce-9" class="widget-1 widget-first widget-last widget-odd widget widget_black_studio_tinymce"><div class="textwidget"><h3>Improving Mobile</h3>
<h3>Banking Experience</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris congue nisi eget justo rutrum, ut pellentesque nulla posuere. Etiam vitae fringilla massa. Aenean sit amet tellus ex.</p>
</div></section> </div>
</div>
</div>
</div>
<div class="anchor_bottom_left"></div>
<div class="anchor_bottom_right"></div>
</section>