Related
I am trying to achieve the following effect:
The code I have is as follows:
.box {
background: #fff;
width: 600px;
height: 100px;
position: relative;
z-index: 999;
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.75);
}
.box::after {
background: linear-gradient(to right, #00a1e4 25%, #ff9a00 25%, #ff9a00 50%, #00a525 50%, #00a525 75%, #8c449d 75%);
position: absolute;
content: "";
height: 10px;
right: 0;
left: 0;
bottom: -10px;
z-index: 1;
}
<div class="box">
</div>
The pseudo element appears ontop of the box shadow in the above example,
how can I get the shadow to appear over the top of the pseudo element?
Here is the example on codepen
You may redraw a shadow inside the pseudo :
.box {
background: #fff;
width:600px;
height:100px;
position: relative;
z-index: 999;
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.75);
}
.box::after {
background: linear-gradient(to right,
#00a1e4 25%,
#ff9a00 25%,
#ff9a00 50%,
#00a525 50%,
#00a525 75%,
#8c449d 75%);
position: absolute;
content: "";
height: 10px;
right: 0;
left: 0;
bottom: -10px;
z-index: 1;
box-shadow: inset 0 5px 4px -3px rgba(0, 0, 0, 0.75);
}
<div class="box">
</div>
you may also use mix-blend-mode :
.box {
background: #fff;
width:600px;
height:100px;
position: relative;
z-index: 999;
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.75);
}
.box::after {
background: linear-gradient(to right,
#00a1e4 25%,
#ff9a00 25%,
#ff9a00 50%,
#00a525 50%,
#00a525 75%,
#8c449d 75%);
position: absolute;
content: "";
height: 10px;
right: 0;
left: 0;
bottom: -10px;
z-index: 1;
mix-blend-mode:multiply;
}
<div class="box">
</div>
I am trying to achieve this shape of div to hold profile information.
So far I've curved one of the corners. However, I am having problems parallel lines.
My HTML:
<div class="profile-card">
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>
My CSS:
.profile-card{
margin-top:150px;
float:right;
background-color: rgba(0,0,0,0.4);
height:500px;
text-align:center;
padding: 50px 40px;
border: 2px solid red;
border-top-left-radius: 39px;
}
The codepen is https://codepen.io/anon/pen/wjMQmw
Thank you in advance.
I would consider a solution with pseudo-element with some skew transformation:
.profile-card {
background: rgba(0, 0, 0, 0.4);
width: 200px;
text-align: center;
padding: 50px 0 0 40px;
border-top-left-radius: 39px;
border-left: 1px solid red;
border-top: 1px solid red;
position: relative;
}
.profile-card:before {
content: "";
position: absolute;
right: -40px;
width: 40px;
top: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.4);
transform: skewY(45deg);
transform-origin: top left;
border-top: 1px solid red;
border-right: 1px solid red;
box-sizing:border-box;
}
.profile-card:after {
content: "";
position: absolute;
bottom: -40px;
height: 40px;
right: 0;
left: 0;
background: rgba(0, 0, 0, 0.4);
transform: skewX(45deg);
border-left: 1px solid red;
border-bottom: 1px solid red;
transform-origin: top left;
box-sizing:border-box;
}
body {
background:linear-gradient(to right,lightblue,pink)
}
<div class="profile-card">
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>
Without the border I would consider multiple gradient to achieve the layout:
.profile-card {
background:
linear-gradient(to bottom left,rgba(0, 0, 0, 0.4) 50%,transparent 51%)0 100%/50px 50px no-repeat,
linear-gradient(to top right,rgba(0, 0, 0, 0.4) 50%,transparent 51%)100% 0/50px 50px no-repeat,
linear-gradient(rgba(0, 0, 0, 0.4),rgba(0, 0, 0, 0.4))100% 100%/calc(100% - 50px) 50px no-repeat,
linear-gradient(rgba(0, 0, 0, 0.4),rgba(0, 0, 0, 0.4))0 0/calc(100% - 50px) 50px no-repeat,
linear-gradient(rgba(0, 0, 0, 0.4),rgba(0, 0, 0, 0.4))0 50px/100% calc(100% - 100px) no-repeat;
width: 200px;
text-align: center;
padding: 50px 40px;
border-top-left-radius: 39px;
}
<div class="profile-card">
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>
Or the clip-path solution:
.profile-card {
background:rgba(0, 0, 0, 0.4);
width: 200px;
text-align: center;
padding: 50px 40px;
border-top-left-radius: 39px;
-webkit-clip-path: polygon(1% 0%, 75% 1%, 100% 30%, 100% 100%, 21% 100%, 0% 74%);
clip-path: polygon(1% 0%, 75% 1%, 100% 30%, 100% 100%, 21% 100%, 0% 74%)
}
<div class="profile-card">
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>
For super complex bordering, one option is to use SVG. Here is an example of basic usage of polygon. SVG embedded into HTML can be styled using CSS easily:
body{
margin:0;
height: 500px;
background: url('https://cdn3.tropicalsky.co.uk/images/1280x720/downtown-dubai-aerial-view.jpg');
}
.profile-card{
margin-top:5px;
background-color: transparent;
height:800px;
width: 200px;
text-align:center;
padding: 50px 40px;
position: relative;
}
.profile-card h1, .profile-card p {
position: relative;
}
.frame {
position: absolute;
top: 20px;
left: 20px;
opacity: 0.7;
}
<div class="profile-card">
<svg class="frame" height="300" width="300">
<polygon points="50 0,250 0,300 50,300 300, 50 300, 0 250, 0 50,7.5 25, 15 15, 25 7.5" style="fill:lightgrey;stroke:orange;stroke-width:1" />
</svg>
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>
I want to achieve something like this -
it has a background image. I only able to make a slanted div like this-
.shape {
position: relative;
width: 100%;
height: 290px;
background: rgba(6, 180, 248, 1);
}
.shape:after {
position: absolute;
width: 100%;
height: 100%;
content: "";
background: inherit;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform-origin: top left;
transform: skewY(-4deg);
}
<br><br><br>
<section class="container">
<div class="shape">
</div>
</section>
but how can I make it transparent with a background image? can anyone please help me
here i tried the example, i hope this will help you ,just copy the entire code in an html page and see the output..., or see snippet below
.hero img {
-webkit-clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
}
.promo {
-webkit-clip-path: polygon(0 0, 1600px 0, 1600px 87%, 0 100%);
clip-path: polygon(0 0, 1600px 0, 1600px 87%, 0 100%);
}
.hero {
color: #fff;
font-family: 'Fira Sans', sans-serif;
position: relative;
text-align: center;
text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5);
}
.hero img {
width: 100%;
}
.hero figcaption {
left: 50%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 100%;
}
.hero h1 {
font-size: 32px;
}
.hero p {
font-size: 14px;
font-weight: 300;
margin-top: 0.5em;
}
.promo {
background: url(https://tractionnext.com/wp-content/uploads/2019/01/book-demo-hero-background.jpg) no-repeat;
background-size: cover;
color: #fff;
font-family: 'Fira Sans', sans-serif;
margin: 50px 0;
overflow: hidden;
padding: 150px 20px;
position: relative;
text-align: center;
text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5);
}
.promo h1 {
font-size: 32px;
}
.promo p {
font-size: 14px;
font-weight: 300;
margin-top: 0.5em;
}
.quote {
background: #41ade5;
position: relative;
z-index: 1;
}
.quote:before, .quote:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.quote:before {
top: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.quote:after {
bottom: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 100%;
transform-origin: 100%;
}
.quote {
color: #fff;
font-family: 'Fira Sans', sans-serif;
margin: 50px 0;
padding: 20% 20px;
text-align: center;
}
h1 {
font-size: 32px;
font-weight: 500;
}
.edge--bottom {
position: relative;
z-index: 1;
}
.edge--bottom:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--bottom:after {
bottom: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 100%;
transform-origin: 100%;
}
.edge--bottom--reverse {
position: relative;
z-index: 1;
}
.edge--bottom--reverse:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--bottom--reverse:after {
bottom: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
}
.edge--top {
position: relative;
z-index: 1;
}
.edge--top:before {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--top:before {
top: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.edge--top--reverse {
position: relative;
z-index: 1;
}
.edge--top--reverse:before {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--top--reverse:before {
top: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.edge--both {
position: relative;
z-index: 1;
}
.edge--both:before, .edge--both:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--both:before {
top: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.edge--both:after {
bottom: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 100%;
transform-origin: 100%;
}
.edge--both--reverse {
position: relative;
z-index: 1;
}
.edge--both--reverse:before, .edge--both--reverse:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--both--reverse:before {
top: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.edge--both--reverse:after {
bottom: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.-berry {
background: #b52b4a;
}
.-blue {
background: #41ade5;
}
.-orange {
background: #de6628;
}
.-green {
background: #5e9b42;
}
.block {
color: #fff;
font-family: 'Fira Sans', sans-serif;
margin: 0 0 200px;
padding: 20% 20px;
text-align: center;
}
h1 {
font-size: 32px;
font-weight: 500;
}
p {
font-size: 14px;
font-weight: 300;
margin-top: 0.5em;
}
<div class="hero">
<figure>
<img src="https://tractionnext.com/wp-content/uploads/2019/01/book-demo-hero-background.jpg" /><figcaption>
<h1>
Angled Edge
</h1>
<p>
Image with CSS clip-path
</p>
</figcaption>
</figure>
</div>
<div class="promo">
<h1>
Angled Edge
</h1>
<p>
CSS background with CSS clip-path
</p>
</div>
<div class="quote">
<h1>
Angled Edges
</h1>
<p>
With 2 Pseudo Elements
</p>
</div>
<div class="block -berry edge--bottom">
<h1>
Bottom Angled Edge
</h1>
</div>
<div class="block -blue edge--bottom--reverse">
<h1>
Bottom Angled Edge
</h1>
<p>
Reversed
</p>
</div>
<div class="block -berry edge--top">
<h1>
Top Angled Edge
</h1>
</div>
<div class="block -blue edge--top--reverse">
<h1>
Top Angled Edge
</h1>
<p>
Reversed
</p>
</div>
<div class="block -orange edge--both">
<h1>
Top & Bottom Angled Edges
</h1>
</div>
<div class="block -green edge--both--reverse">
<h1>
Top & Bottom Angled Edges
</h1>
<p>
Reversed
</p>
</div>
i have tried a new one just look into it , ignore me if you not agree
.hero img {
-webkit-clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
}
.promo {
-webkit-clip-path: polygon(0 0, 1600px 0, 1600px 87%, 0 100%);
clip-path: polygon(0 0, 1600px 0, 1600px 87%, 0 100%);
}
.hero {
color: #fff;
font-family: 'Fira Sans', sans-serif;
position: relative;
text-align: center;
text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5);
}
.hero img {
width: 100%;
}
.hero figcaption {
left: 50%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 100%;
}
.hero h1 {
font-size: 32px;
}
.hero p {
font-size: 14px;
font-weight: 300;
margin-top: 0.5em;
}
.promo {
/*background: url(https://unsplash.it/1600/900?image=830) no-repeat;*/
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.6)), to(rgba(0, 0, 0, 0.6))), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-size: cover;
color: #fff;
font-family: 'Fira Sans', sans-serif;
margin: 50px 0;
overflow: hidden;
padding: 150px 20px;
position: relative;
text-align: center;
text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5);
}
.promo h1 {
font-size: 32px;
}
.promo p {
font-size: 14px;
font-weight: 300;
margin-top: 0.5em;
}
.quote {
background: #41ade5;
position: relative;
z-index: 1;
}
.quote:before, .quote:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.quote:before {
top: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.quote:after {
bottom: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 100%;
transform-origin: 100%;
}
.quote {
color: #fff;
font-family: 'Fira Sans', sans-serif;
margin: 50px 0;
padding: 20% 20px;
text-align: center;
}
h1 {
font-size: 32px;
font-weight: 500;
}
.edge--bottom {
position: relative;
z-index: 1;
}
.edge--bottom:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--bottom:after {
bottom: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 100%;
transform-origin: 100%;
}
.edge--bottom--reverse {
position: relative;
z-index: 1;
}
.edge--bottom--reverse:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--bottom--reverse:after {
bottom: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
}
.edge--top {
position: relative;
z-index: 1;
}
.edge--top:before {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--top:before {
top: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.edge--top--reverse {
position: relative;
z-index: 1;
}
.edge--top--reverse:before {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--top--reverse:before {
top: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.edge--both {
position: relative;
z-index: 1;
}
.edge--both:before, .edge--both:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--both:before {
top: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.edge--both:after {
bottom: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 100%;
transform-origin: 100%;
}
.edge--both--reverse {
position: relative;
z-index: 1;
}
.edge--both--reverse:before, .edge--both--reverse:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--both--reverse:before {
top: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.edge--both--reverse:after {
bottom: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.-berry {
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.6)), to(rgba(0, 0, 0, 0.6))), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
}
.-blue {
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.6)), to(rgba(0, 0, 0, 0.6))), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
}
.-orange {
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.6)), to(rgba(0, 0, 0, 0.6))), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
}
.-green {
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -moz-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -ms-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.6)), to(rgba(0, 0, 0, 0.6))), url("https://unsplash.it/1600/900?image=830");
background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url("https://unsplash.it/1600/900?image=830");
}
.block {
color: #fff;
font-family: 'Fira Sans', sans-serif;
margin: 0 0 200px;
padding: 20% 20px;
text-align: center;
}
h1 {
font-size: 32px;
font-weight: 500;
}
p {
font-size: 14px;
font-weight: 300;
margin-top: 0.5em;
}
<div class="hero">
<figure>
<img src="https://unsplash.it/1600/900?image=830" /><figcaption>
<h1>
Angled Edge
</h1>
<p>
Image with CSS clip-path
</p>
</figcaption>
</figure>
</div>
<div class="promo">
<h1>
Angled Edge
</h1>
<p>
CSS background with CSS clip-path
</p>
</div>
<div class="quote">
<h1>
Angled Edges
</h1>
<p>
With 2 Pseudo Elements
</p>
</div>
<div class="block -berry edge--bottom">
<h1>
Bottom Angled Edge
</h1>
</div>
<div class="block -blue edge--bottom--reverse">
<h1>
Bottom Angled Edge
</h1>
<p>
Reversed
</p>
</div>
<div class="block -berry edge--top">
<h1>
Top Angled Edge
</h1>
</div>
<div class="block -blue edge--top--reverse">
<h1>
Top Angled Edge
</h1>
<p>
Reversed
</p>
</div>
<div class="block -orange edge--both">
<h1>
Top & Bottom Angled Edges
</h1>
</div>
<div class="block -green edge--both--reverse">
<h1>
Top & Bottom Angled Edges
</h1>
<p>
Reversed
</p>
</div>
I hope this helps, I gave linear-gradient in :before of .shape
.shape {
position: relative;
width: 100%;
height: 290px;
background-image: url(https://unsplash.it/1600/900?image=830);
background-size: 100% 290px;
color: #fff;
}
.content {
display: flex;
height: 100%;
align-items: center;
justify-content: center;
}
.shape:before {
position: absolute;
width: 100%;
height: 20%;
content: "";
background: linear-gradient(to right bottom, rgba(255, 255, 255, 1) 50%, transparent 50%);
}
<section class="container">
<div class="shape">
<div class="content">
Some text here
</div>
</div>
</section>
This is my revised version (simplified)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>SLANTED</title>
<style>
body
{
margin:0;
padding:0;
font-family:Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", Verdana, sans-serif;
background: url(https://unsplash.it/1600/900?image=830) no-repeat 0 0;
background-size: 100% auto;
}
*
{
-webkit-box-sizing:border-box;
box-sizing:border-box;
}
h1
{
max-width:80%;
margin:auto;
font-size: 46px;
text-align:center;
padding: 10% 0;
color: #FFF;
}
.container
{
width:100%;
min-height:450px;
}
.container::after {
content: '';
display: block;
width: 100%;
height: 80px;
position: absolute;
transform: skewY(-2deg);
background-color: #fff;
bottom: -45px;
}
</style>
</head>
<body>
<section class="container">
<div class="shape">
<h1>We always do something with pure CSS…</h1>
</div>
</section>
<h2>Sub sections</h2>
<h2>Sub sections</h2>
<h2>Sub sections</h2>
<h2>Sub sections</h2>
<h2>Sub sections</h2>
<h2>Sub sections</h2>
</body>
</html>
I use mutiple Background. I use a before Element in the back of an multibackground with Css3 code and a background-image.
and i have also an other Background called (apc-container)behind this Background.
My problem is that the before Element is also behind the #acp-container.
in the pseudo element before i use the z-index.
i try to use this also in the #acp-container but it does not work.
So how i bring the before pseudo Element in front of the #apc-container and in the back of the #subfilter a BG?
you can check it out with this code and you see the problem easy.
#streams-container,
#acp-container {
border-radius: 10px;
background-color: #f8f8f8;
min-height: 500px;
}
.subfilter {
margin-top: 160px;
}
.subfilter a {
margin-right: 130px;
margin-left: 130px;
width: 145px;
height: 145px;
display: inline-block;
position: relative;
line-height: 145px;
background-size: auto auto, auto auto;
background-color: #eaeaea;
background-image: url(images/Eye.png), -webkit-gradient(linear, left top, left bottom, from(#f6f6f6), to(#eaeaea));
background-image: url(images/Eye.png), -webkit-linear-gradient(top, #f6f6f6, #eaeaea);
background-image: url(images/Eye.png), -moz-linear-gradient(top, #f6f6f6, #eaeaea);
background-image: url(images/Eye.png), -ms-linear-gradient(top, #f6f6f6, #eaeaea);
background-image: url(images/Eye.png), -o-linear-gradient(top, #f6f6f6, #eaeaea);
background-image: url(images/Eye.png), linear-gradient(top, #f6f6f6, #eaeaea);
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .1);
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .1);
box-shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 2px 3px rgba(0, 0, 0, .1);
}
.subfilter a.finiwatch {
background-position: 0px -172px, 0 0;
}
.subfilter a:active {
top: 1px;
}
.subfilter a::before {
content: '';
position: absolute;
z-index: -1;
top: -8px;
right: -8px;
bottom: -8px;
left: -8px;
background-color: #eaeaea;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
opacity: 0.5;
}
.subfilter a:active::before {
top: -9px;
}
.subfilter a:hover::before {
opacity: 1;
}
.subfilter a.finiwatch:hover::before {
background-color: #B3F390;
}
.subfilter a:hover {
top: 0px, 1px;
}
.subfilter a.finiwatch:hover {
background-position: -160px -158px, 0 0;
}
.subfilter a:active {
background: url(images/Eye.png), -moz-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), -webkit-gradient(linear, left top, left bottom, from(#eaeaea), to(#f6f6f6));
background-image: url(images/Eye.png), -webkit-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), -moz-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), -ms-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), -o-linear-gradient(top, #eaeaea, #f6f6f6);
background-image: url(images/Eye.png), linear-gradient(top, #eaeaea, #f6f6f6);
}
.subfilter a.finiwatch:active {
background-position: -318px -158px, 0 0;
}
.subfilter a.finiwatch:selected {
background-position: -318px -158px, 0 0;
}
<div id="streams-container">
<div class="subfilter">
<a class="finiwatch" href=""></a>
</div>
For everyone stumbling accross this...
#streams-container {
border-radius: 10px;
background-color: #f8f8f8;
min-height: 500px;
position: relative;
z-index: 1;
}
.subfilter {
margin-top: 160px;
}
.subfilter a {
margin-right: 130px;
margin-left: 130px;
width: 145px;
height: 145px;
display: inline-block;
position: relative;
line-height: 145px;
background-size: auto auto, auto auto;
background-color: blue;
}
.subfilter a.finiwatch {
background-position: 0px -172px, 0 0;
}
.subfilter a::before {
content: '';
position: absolute;
z-index: 10;
top: -8px;
right: -8px;
bottom: -8px;
left: -8px;
background-color: pink;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
opacity: 0.5;
}
.subfilter a:active::before {
top: -9px;
}
.subfilter a:hover::before {
opacity: 1;
}
.subfilter a.finiwatch:hover::before {
background-color: #B3F390;
}
.subfilter a:hover {
top: 0px, 1px;
}
.subfilter a.finiwatch:hover {
background-position: -160px -158px, 0 0;
}
<div id="streams-container">
<div class="subfilter">
<a class="finiwatch" href=""></a>
</div>
</div>
Found a way
give apc-container a relative position and a z-index of 1 and teh before element a z-index of -10.
#streams-container,
#acp-container {
border-radius: 10px;
background-color: #f8f8f8;
min-height: 500px;
position: relative;
z-index: 1;
}
.subfilter a::before {
content: '';
position: absolute;
z-index: -10;
top: -8px;
right: -8px;
bottom: -8px;
left: -8px;
background-color: #eaeaea;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
opacity: 0.5;
}
I am trying to create this image with css and html but m kept failing to get perfect curve and shadow as shown in image.
HTML
<div class="mainDiv">
<div class="square"></div>
<div class="square2"></div>
<div class="square3"></div>
</div>
CSS
.mainDiv{
position: relative;
width: 206px;
height: 190px;
margin: 0px auto;
margin-top:100px;
}
.square{
width:100px;
height:100px;
background:#df1c40;
float:left;
transform: skew(180deg,210deg);
position: absolute;
top: 42px;
}
.square2{
width:100px;
height:100px;
background:#ff9c28;
float:left;
transform: skew(180deg,150deg);
position: absolute;
left:100px;
top: 42px;
}
.square3{
width:117px;
height:100px;
background:#97bbdd;
float:left;
transform: rotate(150deg) translate(-40px, -16px) skew(30deg, 0deg);
position: absolute;
left: -1px;
top: -31px;
}
.square3:before {
content: "";
position: absolute;
top: 0%;
right: 0%;
width: 0px;
height: 0px;
border-bottom: 70px solid #28a55c;
border-left: 70px solid transparent;
-webkit-box-shadow: 5px 0px 0px -1px #879fd1;
-moz-box-shadow: 5px 0px 0px -1px #879fd1;
box-shadow: 5px 0px 0px -1px #879fd1;
transform: rotate(90deg);
}
.square3:after {
content: "";
position: absolute;
top: 0%;
right: 0%;
width: 0px;
height: 0px;
border-top: 70px solid #F3F5F6;
border-right: 70px solid transparent;
transform: rotate(90deg);
}
My best try. I am just doing this for my knowledge and any help with little bit detail will be appreciate.. :)
The curved areas in the top can be achieved to some extent using radial-gradient for background instead of using the border method to create the triangles.
This works in Chrome (v51.0.2704.7 dev-m), Opera (v36.0), Firefox (v45.0.2), Edge and IE11. It also works in Safari (tested on iPhone).
.mainDiv {
position: relative;
width: 206px;
height: 190px;
margin: 0px auto;
margin-top: 100px;
}
.square {
width: 100px;
height: 100px;
background: #df1c40;
float: left;
transform: skew(180deg, 210deg);
position: absolute;
top: 42px;
}
.square2 {
width: 100px;
height: 100px;
background: #ff9c28;
float: left;
transform: skew(180deg, 150deg);
position: absolute;
left: 100px;
top: 42px;
}
.square3 {
width: 117px;
height: 100px;
background: #97bbdd;
float: left;
transform: rotate(150deg) translate(-40px, -16px) skew(30deg, 0deg);
position: absolute;
left: -1px;
top: -31px;
overflow: hidden;
}
.square3:before {
content: "";
position: absolute;
top: 0%;
right: 0%;
width: 70px;
height: 70px;
padding: 0px 8px 0px 0px;
background: radial-gradient(ellipse 100px 35px at 45% 110%, #97bbdd 50%, rgb(40, 165, 92) 52%, rgb(40, 165, 92) 55%, transparent 56%);
background-size: 90% 100%;
background-repeat: no-repeat;
transform: rotate(90deg);
}
.square3:after {
content: "";
position: absolute;
top: 0%;
right: 0%;
width: 62px;
height: 70px;
padding: 0px 8px 0px 0px;
background: radial-gradient(ellipse 20px 90px at 110% 50%, transparent 50%, rgb(40, 165, 92) 50%, rgb(40, 165, 92) 62%, transparent 63%), radial-gradient(ellipse 20px 90px at 110% 50%, transparent 50%, rgb(138, 159, 212) 50%, rgb(138, 159, 212) 60%, transparent 70%), linear-gradient(to bottom right, white 45%, rgb(40, 165, 92) 46%), linear-gradient(to bottom right, white 48%, rgb(138, 159, 212) 49%);
background-clip: border-box, border-box, content-box, border-box;
background-size: 95% 100%, 100% 85%, 100% 100%, 95% 85%;
background-repeat: no-repeat;
transform: rotate(90deg);
z-index: -1;
}
<div class="mainDiv">
<div class="square"></div>
<div class="square2"></div>
<div class="square3"></div>
</div>
i played also with gradient from a single div and 2 pseudos:
The idea is to pile bits of gradients to shape the curved parts.
#cube{
display: inline-flex;
align-items: center;
justify-content: center;
background: #DF1C40;
color: white;
width: 75px;
height: 182px;
margin: 78px;
position: relative;
transform: skew(40deg, 10deg) rotate(40deg);
}
#cube:before,
#cube:after {
display: inherit;
align-items: center;
justify-content: center;
content: '';
position: absolute;
top: 0;
left: 0px;
right: 0px;
bottom: 0;
background: #FF9D28;
border-radius: inherit;
box-shadow: inherit;
transform: translate(100%, -50%) skew( 0deg, -67deg) rotate(0deg);
}
#cube:after {
content: '';
top: 0px;
left: 0;
height: 106%;
right: 0;
width: 85%;
bottom: 0;
transform: translate(68%, -96%) rotate(30deg)skew(7deg, -30deg);
background:
linear-gradient(to top left, white 42%, transparent 43%),
linear-gradient(141deg, transparent 80%, white 75%),
linear-gradient(-265deg, transparent 80%, white 75%),
linear-gradient(-5deg, #28A55c 45%, transparent 46%) 20px -6px no-repeat,
linear-gradient(25deg, #28A55c 45%, transparent 46%) 7px 38px no-repeat,
linear-gradient(-97deg, #28A55c 44%, transparent 46%) 2px 38px no-repeat,
linear-gradient(140deg, transparent 45%, #28A55c 46%) 22px 16px no-repeat,
linear-gradient(265deg, #28A55c 0%, transparent 0%) -17px 46px no-repeat,
linear-gradient(272deg, #28A55c 50%, transparent 51%) -7px 120px no-repeat,
linear-gradient(267deg, #28A55c 50%, transparent 51%) -13px 75px no-repeat,
linear-gradient(265deg, #28A55c 45% , transparent 46% ) -20px 46px no-repeat,
linear-gradient(-95deg, rgba(0, 0, 0, 0.1) 45%, transparent 46%) -23px 48px no-repeat,
linear-gradient(to bottom right, #97BBDD 58%, transparent 58%);
background-size: 100% 100%, auto, auto, 60% 50%,60% 5%,13% 10%, 60% 45%, 100% 70%, 60% 45%, 80% 45%, auto;
}
body {
background:#333;
font-family:tahoma;
font-weight:bold
}
p {position:absolute;color:white;}
<p>wich is which ?</p>
<div id="cube">
CSS <br/> box
</div>
<img src="http://i.stack.imgur.com/0Y3vw.png"/>
codepen to play with
I have played with linear-gradient & Position property to get similar design.
As you can see i had to take few extra element for curve. For more detail about corner read here
Hope it will help..
.mainDiv{
position: relative;
width: 206px;
height: 190px;
margin: 0px auto;
margin-top:100px;
}
.square{
width:100px;
height:100px;
background:#df1c40;
float:left;
transform: skew(180deg,210deg);
position: absolute;
top: 42px;
}
.square2{
width:100px;
height:100px;
background:#ff9c28;
float:left;
transform: skew(180deg,150deg);
position: absolute;
left:100px;
top: 42px;
}
.square3{
width:117px;
height:100px;
background:#97bbdd;
float:left;
transform: rotate(150deg) translate(-40px, -16px) skew(30deg, 0deg);
position: absolute;
left: -1px;
top: -31px;
}
.square3:before {
content: "";
position: absolute;
top: 2%;
right: 0%;
left: 44%;
width: 0px;
height: 0px;
border-bottom: 60px solid transparent;
border-left: 60px solid transparent;
-webkit-box-shadow: 6px 0px 0px -1px #879fd1;
-moz-box-shadow: 6px 0px 0px -1px #879fd1;
box-shadow: 6px 0px 0px -1px #879fd1;
transform: rotate(84deg);
z-index:0;
}
.square3:after {
content: "";
position: absolute;
top: 0%;
right: 0%;
width: 0px;
height: 0px;
border-top: 73px solid #FFF;
border-right: 73px solid transparent;
transform: rotate(90deg);
}
#fpc_page-tip:before, #fpc_page-tip:after {
background-color: #FFF;
position: absolute;
display: block;
z-index: 2;
border-top-right-radius: 60%;
width: 50%;
height: 50%;
content: "";
}
#fpc_page-tip:before {
right: 96%;
top: 0%;
background: -webkit-radial-gradient(-180% 200%, circle, rgba(151,187,221,1) 85%, rgba(135,159,209,.8) 93%);
border-right: solid 2px #28A55C;
box-shadow: 17px -3px 1px -18px #FFF;
z-index: -1;
}
#fpc_page-tip:after {
top: 96%;
right: 0%;
background: -webkit-radial-gradient(-250% 320%, circle, rgba(151,187,221,0) 85%, rgba(135,159,209,.8) 93%);
border-top: solid 2px #28A55C;
box-shadow: 17px -3px 1px -18px #FFF;
z-index: 0;
}
#fpc_corner-box { /* edit these sizes for the default revealing corner size */
height: 20px;
width: 20px;
right: 0;
top: 0;
position: absolute;
overflow: visible;
height: 65px;
width: 65px;
}
#fpc_corner-box:before {
position: absolute;
top: 0;
right: 0;
/*content: "";*/
display: block;
width: 100%;
height: 100%;
}
#fpc_page-tip {
position: absolute;
top: 0;
right: 0;
content: "";
background: -webkit-linear-gradient(45deg, #28a55c 17%, #28a55c 18%, #48A26E 30%, #41A76B 34%, #2FCA70 49%, rgba(200,200,200,0) 36%);
display: block;
width: 100%;
height: 100%;
}
#fpc_corner-box, #fpc_page-tip {
-webkit-transition-property: all;
-webkit-transition-duration: .3s;
-webkit-transition-timing-function: cubic-bezier(0, 0.35, .5, 1.7);
}
<div class="mainDiv">
<div class="square"></div>
<div class="square2"></div>
<div class="square3">
<div id="fpc_corner-box">
<a id="fpc_page-tip" href="#">
</a>
</div>
</div>
</div>