Displaying a shadow ontop of pseudo element - html

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>

Related

Cascading divs with triangles pointing downwards

What would be the easiest way to create the following (see image) with triangles at the bottom of the div.
I have tried using the css after method but get overlapping triangles. I am thinking the easiest way maybe to just create background images of the triangle on each div.
.triangle {
position: relative;
margin: 0;
padding: 1em;
box-sizing: border-box;
background: white;
box-shadow: 0px 3px 3px 0 rgba(0, 0, 0, 0.4);
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0px;
margin-left: -0.5em;
bottom: -2em;
left: 80%;
box-sizing: border-box;
border: 1em solid black;
border-color: transparent transparent white white;
transform-origin: 0 0;
transform: rotate(-45deg);
box-shadow: -3px 3px 3px 0 rgba(0, 0, 0, 0.4);
}
This seems a perfect job for clip-path:
.container {
padding:20px;
background:#dce2cc;
}
.box {
height:200px;
clip-path: polygon(0 0, calc(70% - 30px) 0, 70% 15%, calc(70% + 30px) 0, 100% 0, 100% 85%, calc(70% + 30px) 85%, 70% 100%, calc(70% - 30px) 85%, 0 85%);
background-color:red;
background-size:cover;
background-position:center;
}
.box:first-child {
clip-path: polygon(0 0, 100% 0, 100% 85%, calc(70% + 30px) 85%, 70% 100%, calc(70% - 30px) 85%, 0 85%);
}
.box:last-child {
clip-path: polygon(0 0, calc(70% - 30px) 0, 70% 15%, calc(70% + 30px) 0, 100% 0, 100% 100%,0 100%);
}
.box:not(:first-child) {
margin-top:-10px;
}
<div class="container">
<div class="box" style="background-image:url(https://picsum.photos/500/500?image=0)"></div>
<div class="box" style="background-image:url(https://picsum.photos/500/500?image=1069)"></div>
<div class="box" style="background-image:url(https://picsum.photos/500/500?image=1072)"></div>
<div class="box" style="background-image:url(https://picsum.photos/500/500?image=1052)"></div>
</div>
you can achieve this using css :after and :before see below working snippet
body{
background:rgb(220, 226, 204);
}
.arrow {
position: relative;
background: #fff;
height:100px;
margin-top:10px;
}
.arrow:after, .arrow:before {
top: 88%;
left: 80%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
z-index: 1;
filter: drop-shadow(0px 12px 0px rgb(220, 226, 204));
-webkit-filter: drop-shadow(0px 12px 0px rgb(220, 226, 204));
}
.arrow:after {
border-color: rgba(194, 225, 245, 0);
border-top-color: #fff;
border-width: 35px;
margin-left: -35px;
}
.arrow:before {
border-color: rgba(194, 225, 245, 0);
border-top-color: #fff;
border-width: 38px;
margin-left: -38px;
}
.arrow.no-arrow:after,.arrow.no-arrow:before{
display:none;
}
<div class="arrow">
content goes here
</div>
<div class="arrow">
content goes here
</div>
<div class="arrow no-arrow">
content goes here
</div>

How change the shape of div corners?

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>

Css - Create header gradient and pattern

Is there any way to made the same style like in the image with CSS?
HTML5 allows us to draw multiple background images on any element. We can use CSS3's linear-gradient() and repeating-linear-gradient() functions to create 2 background images and draw them on the respective element.
Following code will create the background you need:
#header {
background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,0.15),
rgba(255,255,255,0.15) 15px,
transparent 15px,
transparent 25px),
linear-gradient(to bottom, brown, red);
}
Note: Order of images in background-image property is important. Swapping
them won't create the effect you need.
Output Image:
Working Demo:
#header {
background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,0.15), rgba(255,255,255,0.15) 15px, transparent 15px, transparent 25px), linear-gradient(to bottom, brown, red);
height: 80px;
border-radius: 5px 5px 0 0;
}
<header id="header"></header>
Try the below CSS
<div class="meter red">
<span style="width: 25%"></span>
</div>
.meter {
height: 20px; /* Can be anything */
position: relative;
-moz-border-radius: 25px;
-webkit-border-radius: 25px;
border-radius: 25px;
box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3);
}
.meter > span {
display: block;
height: 100%;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
background-color: rgb(43,194,83);
background-image: linear-gradient(
center bottom,
rgb(43,194,83) 37%,
rgb(84,240,84) 69%
);
box-shadow:
inset 0 2px 9px rgba(255,255,255,0.3),
inset 0 -2px 6px rgba(0,0,0,0.4);
position: relative;
overflow: hidden;
}
.red > span {
background-color: #f0a3a3;
background-image: linear-gradient(to bottom, #f0a3a3, #f42323);
}
.meter > span:after {
content: "";
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
background-image: linear-gradient(
-45deg,
rgba(255, 255, 255, .2) 25%,
transparent 25%,
transparent 50%,
rgba(255, 255, 255, .2) 50%,
rgba(255, 255, 255, .2) 75%,
transparent 75%,
transparent
);
z-index: 1;
background-size: 50px 50px;
animation: move 2s linear infinite;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
border-top-left-radius: 20px;
border-bottom-left-radius: 20px;
overflow: hidden;
}

How to create Cube with inner shadow to corner with curve?

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>

How I create this CSS3 page curl effect?

I am trying to create a page curl effect using CSS3. That effect should be something similar to this -
I tried to get it to work but couldn't figure it out.
This is my code sofar
.nav {
width: 200px;
background: #353942;
height: 50px;
position: relative;
}
.curl {
width:70px;
height:50px;
position: absolute;
top:0;
right:0;
background: linear-gradient(
25deg,
#4c4c4c 0%,
#474747 39%,
#2c2c2c 50%,
#000000 51%,
#111111 60%,
#2b2b2b 76%,
#1c1c1c 91%,
#131313 100%);
box-shadow : 0 0 10px rgba(0,0,0,0.5);
transition: all .5s ease;
}
.curl:before,
.curl:after {
content: '';
position: absolute;
z-index: -1;
left: 12.5%;
bottom: 5.8%;
width: 70%;
max-width: 300px;
max-height: 100px;
height: 55%;
box-shadow: 0 12px 15px rgba(0, 0, 0, 0.3);
transform: skew(-10deg) rotate(-6deg);
}
.curl:after {
left: auto;
right: 5.8%;
bottom: auto;
top: 14.16%;
transform: skew(-25deg) rotate(-84deg);
}
.curl:hover {
width: 120px;
height: 50px;
}
.curl:hover:before,
.curl:hover:after {
box-shadow: 0 24px 30px rgba(0, 0, 0, 0.3);
}
This is JS BIN
Can anybody tell me how I figure this out?
Any ideas would be greatly appreciated.
Thank you.
check this out.
.nav {
width: 200px;
background: #353942;
height: 50px;
position: relative;
}
.curl {
width:120px;
height:120px;
position: absolute;
top:0;
left:0;
background :
linear-gradient(
135deg,
#fff,
#f3f3f3 45%,
#ddd 50%,
#aaa 50%,
#bbb 56%,
#ccc 62%,
#f3f3f3 80%,
#fff 100%
);
box-shadow : 0 0 10px rgba(0, 0, 0, .5);
transition: all .5s ease;
}
.curl:before,
.curl:after {
content: '';
position: absolute;
z-index: -1;
left: 12.5%;
bottom: 5.8%;
width: 70%;
max-width: 300px;
max-height: 100px;
height: 55%;
box-shadow: 0 12px 15px rgba(0, 0, 0, .3);
transform: skew(-10deg) rotate(-6deg);
}
.curl:after {
left: auto;
right: 5.8%;
bottom: auto;
top: 14.16%;
transform: skew(-15deg) rotate(-84deg);
}
.curl:hover {
width: 240px;
height: 240px;
}
.curl:hover:before,
.curl:hover:after {
box-shadow: 0 24px 30px rgba(0, 0, 0, .3);
}