Related
I applied this code to make the content underneath a div blurry, but the edge is very sharp.
z-index: 10;
backdrop-filter: blur(10px);
background: rgb(255,255,255);
background: linear-gradient(0deg, rgba(255,255,255,0) 10%, rgba(174,174,174,0) 15%, var(--bg-color) 85%);
Can I create something like a blur gradient to soften the edge and make the blur gradually disappear?
To make Tilt-Shift effect for backdrop-filter in CSS, You have to use the mask-image attribute like the code below:
CSS:
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
-webkit-mask-image: linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, black 20%, black 100%);
mask-image: linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, black 20%, black 100%);
You can change the position of tilting by percent, but I think this config is exactly what you need.
.menu{
color: white;
position: sticky;
display: flex;
place-content: space-evenly;
align-items: center;
height: 80px;
}
.menu:before {
content: '';
height: 80px;
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: -1;
-webkit-backdrop-filter: blur(15px);
backdrop-filter: blur(15px);
-webkit-mask-image: linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, black 40%, black 100%);
mask-image: linear-gradient(0deg, rgba(0, 0, 0, 0) 0%, black 40%, black 100%);
}
body{
width: 100%;
height: 100vh;
background: url("https://images.unsplash.com/photo-1444080748397-f442aa95c3e5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8M3x8fGVufDB8fHx8&w=1000&q=80");
background-repeat: no-repeat;
background-size: cover;
margin: 0;
}
<body>
<div class="menu">
<span>Home</span>
<span>About</span>
<span>Contact</span>
</div>
</body>
I'm trying to animate a rotating gold ray of lights, below image is the achieved layout using html and css but when I tried to add a rotate animation, seems layout cut on half. Below code snippet is what is my attempt. Any help, ideas is greatly appreciated.
#import('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css');
body {
background: #ededed;
padding: 64px 0;
font-family: Roboto, sans-serif;
font-size: 12px
}
.banner {
max-width: 100%;
max-height: 100%;
-webkit-box-shadow: 0 10px 40px -6px rgba(0, 0, 0, .1);
-moz-box-shadow: 0 10px 40px -6px rgba(0, 0, 0, .1);
-o-box-shadow: 0 10px 40px -6px rgba(0, 0, 0, .1);
box-shadow: 0 10px 40px -6px rgba(0, 0, 0, .1)
}
.winners-intro {
background: #ededed;
z-index: 999
}
.winners-intro,
.winners-intro .winners-light {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
position: fixed;
top: 0;
left: 0
}
.winners-intro .winners-light {
-webkit-animation-name: winners_light;
-webkit-animation-duration: 10s;
-webkit-animation-iteration-count: infinite;
animation-name: winners_light;
animation-duration: 10s;
animation-iteration-count: infinite
}
.winners-intro .winners-light .radial-light {
width: 100px;
height: 100px;
background: gold;
box-shadow: 1px 1px 100px 50px gold;
-webkit-box-shadow: 1px 1px 100px 50px gold;
-moz-box-shadow: 1px 1px 100px 50px gold;
-o-box-shadow: 1px 1px 100px 50px gold;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
position: absolute
}
.winners-intro .winners-light .light {
position: absolute;
background: gold;
height: 200vh;
width: 20px;
opacity: .5;
background: transparent;
background: -webkit-linear-gradient(bottom, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent);
background: linear-gradient(0deg, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent)
}
.winners-intro .winners-light .light:nth-child(2) {
transform: skewX(30deg)
}
.winners-intro .winners-light .light:nth-child(2),
.winners-intro .winners-light .light:nth-child(3) {
background: transparent;
background: -webkit-linear-gradient(bottom, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent);
background: linear-gradient(0deg, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent)
}
.winners-intro .winners-light .light:nth-child(3) {
transform: skewX(60deg)
}
.winners-intro .winners-light .light:nth-child(4) {
transform: skewX(90deg)
}
.winners-intro .winners-light .light:nth-child(4),
.winners-intro .winners-light .light:nth-child(6) {
background: transparent;
background: -webkit-linear-gradient(bottom, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent);
background: linear-gradient(0deg, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent)
}
.winners-intro .winners-light .light:nth-child(6) {
transform: skewX(-30deg)
}
.winners-intro .winners-light .light:nth-child(7) {
transform: skewX(-60deg);
background: transparent;
background: -webkit-linear-gradient(bottom, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent);
background: linear-gradient(0deg, transparent 27%, gold 50%, transparent 73%, transparent 90%, transparent)
}
.winners-intro .winners-light .light:nth-child(8) {
width: 100%!important;
height: 10px!important;
background: transparent;
background: -webkit-linear-gradient(left, transparent 10%, gold 50%, transparent 90%, transparent);
background: linear-gradient(90deg, transparent 10%, gold 50%, transparent 90%, transparent)
}
.winners-intro .winners-trophy {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 10
}
#-webkit-keyframes winners_light {
to {
transform: rotate(-1turn)
}
}
#keyframes clouds {
to {
transform: rotate(-1turn)
}
}
<div class="winners-intro">
<div>
<div class="winners-light">
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="light"></div>
<div class="radial-light"></div>
</div>
</div>
</div>
I would simplify the code like below where you will not have the issue:
body {
background: #ededed;
margin:0;
overflow:hidden;
display:flex;
align-items:center;
justify-content:center;
height:100vh;
}
.light {
height: 100vmax;
width:100vmax;
background:
radial-gradient(circle ,rgba(255, 215, 0, 1 ) 8vmax,transparent 8vmax),
radial-gradient(circle ,rgba(255, 215, 0, 0.6)8vmax,transparent 17vmax),
linear-gradient(to bottom, transparent 10%,gold,transparent 90%) center/10px 100%,
linear-gradient(to right , transparent 10%,gold,transparent 90%) center/100% 10px;
background-repeat:no-repeat;
position:relative;
overflow:hidden;
animation:move 5s linear infinite;
}
.light:before,
.light:after{
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background:inherit;
background-size:0 0,0 0,10px 100%,100% 10px;
transform:rotate(30deg);
}
.light:after{
transform:rotate(-30deg);
}
#keyframes move {
to {
transform:rotate(1turn);
}
}
<div class="light"></div>
I have a card with a flip effect when hovering it. The card has a background image, and each side has a color to transparent gradient.
When the card flips, the background-image position is on top, over gradient and div content. Without background-image the effect is fine.
How can I solve this issue and put the image under content and gradient?
Here is a codepen with the code https://codepen.io/ramonsan/pen/QJpgrv
.flip-card {
perspective: 1000px;
height: 400px;
width: 300px;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-card-front,
.flip-card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
padding: 1em;
padding-top: 5rem;
}
.flip-card-front {
background: -moz-linear-gradient(top, rgba(100, 153, 210, 1) 28%, rgba(109, 165, 218, 1) 55%, rgba(125, 185, 232, 0) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(100, 153, 210, 1) 28%, rgba(109, 165, 218, 1) 55%, rgba(125, 185, 232, 0) 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(100, 153, 210, 1) 28%, rgba(109, 165, 218, 1) 55%, rgba(125, 185, 232, 0) 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6499d2', endColorstr='#007db9e8', GradientType=0);
/* IE6-9 */
color: white;
}
.flip-card-back {
transform: rotateY(180deg);
background: -moz-linear-gradient(top, rgba(255, 255, 255, 1) 1%, rgba(255, 255, 255, 1) 10%, rgba(255, 255, 255, 0.5) 80%, rgba(255, 255, 255, 0) 100%);
/* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(255, 255, 255, 1) 1%, rgba(255, 255, 255, 1) 10%, rgba(255, 255, 255, 0.5) 80%, rgba(255, 255, 255, 0) 100%);
/* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 1%, rgba(255, 255, 255, 1) 10%, rgba(255, 255, 255, 0.5) 80%, rgba(255, 255, 255, 0) 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#00ffffff', GradientType=0);
/* IE6-9 */
}
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
<div class="flip-card col-6 col-md-4 pb-4 mb-0">
<div class="flip-card-inner" style="background-image: url(https://images.wallpaperscraft.com/image/glare_circles_spots_background_dots_bright_61905_240x400.jpg);">
<div class="flip-card-front">
<h1>FRONT</h1>
</div>
<div class="flip-card-back">
<h2>Back</h2>
</div>
</div>
</div>
Consider using the background image inside the inner divs. I used a CSS variable to make it easy to handle and avoid defining the image within the CSS so you can keep adjusting it through the inline style.
.flip-card {
perspective: 1000px;
height: 400px;
width: 300px;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-card-front,
.flip-card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
padding: 1em;
padding-top: 5rem;
}
.flip-card-front {
background:
linear-gradient(to bottom, rgba(100, 153, 210, 1) 28%, rgba(109, 165, 218, 1) 55%, rgba(125, 185, 232, 0) 100%),
var(--i);
color: white;
}
.flip-card-back {
transform: rotateY(180deg);
background:
linear-gradient(to bottom, rgba(255, 255, 255, 1) 1%, rgba(255, 255, 255, 1) 10%, rgba(255, 255, 255, 0.5) 80%, rgba(255, 255, 255, 0) 100%),
var(--i);
}
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
<div class="flip-card col-6 col-md-4 pb-4 mb-0">
<div class="flip-card-inner" style="--i: url(https://images.wallpaperscraft.com/image/glare_circles_spots_background_dots_bright_61905_240x400.jpg);">
<div class="flip-card-front">
<h1>FRONT</h1>
</div>
<div class="flip-card-back">
<h2>Back</h2>
</div>
</div>
</div>
I'm trying to create a light effect with CSS and HTML only. Just like this image
I don't know if it's possible. or how to do it.
Any help will be appreciated.
.circle {
border: 10px solid;
border-radius: 50%;
width: 200px;
height: 200px;
background-color: green;
}
<div class="circle"></div>
Here is my example
*,
*:before,
*:after {
box-sizing: border-box;
}
div {
width: 120px;
height: 120px;
border-radius: 60px;
background: linear-gradient(to bottom, #393939 0%, #151515 100%);
position: relative;
}
div:before {
content: '';
width: 106px;
height: 106px;
border-radius: 53px;
background: #19f000;
border: 1px solid black;
position: absolute;
left: 7px;
top: 7px;
}
div:after {
content: '';
width: 80px;
height: 60px;
border-radius: 50%;
background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
position: absolute;
transform: rotate(-18deg);
left: 13px;
top: 9px;
}
<div></div>
JSfiddle Demo
You can use a second div for the highlight to try and provide a stronger 3D effect, freeing up the box-shadow to be used for the darker contouring on the edges.
.circle {
width: 164px;
height: 164px;
background-color: #19f000;
border-radius: 100%;
position: relative;
border: 10px solid #444444;
box-shadow: 0 0 15px 0 rgba(0,0,0,.8) inset;
transform: rotate(-20deg);
}
.highlight {
position: absolute;
top: 2px;
right: 0;
left: 0;
margin: auto;
width: 80%;
height: 64%;
opacity: .92;
border-radius: 100%;
/* gratuitous gradient compatibility - activate! */
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(255,255,255,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#00ffffff',GradientType=0 ); /* IE6-9 */
}
<div class="circle">
<div class="highlight"></div>
</div>
You can do with the combination of radial gradient and a pseudo element for glossy effect.
The transition from white to green can be produced through radial-gradient. The #fff color stops at 5%.
The glossy effect finish is given using the opacity on the pseudo element and has a similar shape of the parent with white background and reduced width.
JSfiddle Demo
.circle::after {
background: white none repeat scroll 0 0;
border-radius: 50%;
content: " ";
display: block;
height: 100px;
opacity: 0.15;
position: absolute;
width: 150px;
left: 20px;
}
.circle {
background-image: radial-gradient(ellipse at 50px 10px , #ffffff 0%, #fff 5%, #00ff00 100%);
border: 10px solid;
border-radius: 50%;
height: 200px;
position: relative;
width: 200px;
}
<div class="circle">
</div>
You can do it using a single element also by layering one radial-gradient image of the required size on top of an angled linear-gradient image and then positioning it appropriately. Multiple background images and layering has very good browser support (IE9+) but gradients are supported only in IE10+.
.circle {
border: 10px solid;
border-radius: 50%;
width: 200px;
height: 200px;
background: radial-gradient(ellipse at 90px 45px, rgba(255, 255, 255, 0.75) 10%, rgba(255,255,255,0.5) 30%, rgba(255,255,255,0) 32%, rgba(25,240,0,1) 45%), linear-gradient(160deg, transparent 12%, rgb(25, 240, 0) 30%);
background-size: 125% 80%, 100% 100%;
background-repeat: no-repeat;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<div class="circle"></div>
Browser Compatibility Charts:
Multiple background images and layering
Gradients
<!doctype html>
<html>
<head>
<style>
.circle {
border:10px solid;
border-radius: 50%;
width: 200px;
height: 200px;
background: rgb(25,240,0); /* Old browsers */
background: -moz-linear-gradient(top, rgba(25,240,0,1) 0%, rgba(255,255,255,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(25,240,0,1)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(25,240,0,1) 0%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(25,240,0,1) 0%,rgba(255,255,255,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(25,240,0,1) 0%,rgba(255,255,255,1) 100%); /* IE10+ */
background: linear-gradient(to top, rgba(25,240,0,1) 0%,rgba(255,255,255,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#19f000', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */
}
</style>
<head>
<body>
<div class="circle">
</div>
</body>
</html>
Please use background gradient color as mentioned above. i hope this woould helpful to you
here is the working demo.Demo
Try box shadow like this: Updated Demo
Adjust the shadow values and background gradient colors according to your need.
.circle {
border:10px solid;
border-radius: 50%;
width: 200px;
height: 200px;
background: #f8ffe8;
background: url(data:image/svg+xml;
base64, PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2Y4ZmZlOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjE3JSIgc3RvcC1jb2xvcj0iIzU2YmM2YyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMxOTliMDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #f8ffe8 0%, #56bc6c 17%, #199b00 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f8ffe8), color-stop(17%, #56bc6c), color-stop(100%, #199b00));
background: -webkit-linear-gradient(top, #f8ffe8 0%, #56bc6c 17%, #199b00 100%);
background: -o-linear-gradient(top, #f8ffe8 0%, #56bc6c 17%, #199b00 100%);
background: -ms-linear-gradient(top, #f8ffe8 0%, #56bc6c 17%, #199b00 100%);
background: linear-gradient(to bottom, #f8ffe8 0%, #56bc6c 17%, #199b00 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f8ffe8', endColorstr='#199b00', GradientType=0);
-webkit-box-shadow: inset -1px 60px 68px -28px rgba(255, 255, 255, 1);
-moz-box-shadow: inset -1px 60px 68px -28px rgba(255, 255, 255, 1);
box-shadow: inset -1px 60px 68px -28px rgba(255, 255, 255, 1);
}
I'm attempting to create a button style for a client, and cannot seem to get it working using the after pseudo-class.
<style>
$varBase: 40px;
$imsblue: #012169;
$imsgrey: #012169;
body {
background:grey;
}
.btn {
position: relative;
float: left;
height: $varBase;
font-family: sans-serif;
text-align: center;
line-height: $varBase;
color: white;
white-space: nowrap;
text-transform: uppercase;
background: $imsblue;
&:before {
float: left;
content:"";
width: ($varBase/4);
height: ($varBase/2);
}
&:after {
position: absolute;
content:"";
height: ($varBase/2);
border-left: ($varBase/2) solid $imsblue;
border-bottom: ($varBase/2) solid transparent;
}
a {
color: white;
text-decoration:none;
padding: ($varBase/4) ($varBase/2);
margin-right: -10px;
}
}
.btn3 {
display: inline;
color: white;
background: linear-gradient(135deg, rgba(1,33,105,1) 0%, rgba(1,33,105,1) 93%, rgba(30, 87, 153, 0) 93%, rgba(30, 87, 153, 0) 100%);
outline: 0;
border: 0;
padding: 10px 0px;
a {
color: inherit ;
text-transform: uppercase;
text-decoration:none;
padding: ($varBase/4) $varBase;
}
}
</style>
<div class="btn">Click to Submit</div>
<div class="btn3">Click to Submit</div>
I can get it to show using two DIVs, but I need this to work with just one class. Can someone help me see what I'm doing wrong?
It's supposed to look like this (barring color and size of course):
I believe the key element missing is that you need to include a content:"" in your :after pseudoclass. See the example below.
.btn {
height: 40px;
background: red;
width: 128px;
float:left;
}
.btn:after {
width: 0px;
height: 20px;
border-left: 20px solid red;
border-bottom: 20px solid white;
float:right;
content:"";
}
<div class="btn">Button</div>
This will work - I had to convert your SCSS to CSS, but it's clear enough.
.btn {
height: 40px; width: 200px;
background: red;
position: relative; /* work as container */
}
.btn:after {
content: ''; /* needed */
display: block;
position: absolute; /* position to container */
right: 0; bottom: 0;
border-left: 20px solid red;
border-bottom: 20px solid white;
}
<div class="btn">Button</div>
Unfortunately, you can't have "transparent" overlay, it just wont work. I had to use white for it.
I found a solution that works where the "cut" is transparent. You can use regular background or image background for the button:
http://jsfiddle.net/q45w2f78/
<div class="buttoncut gon">My button</div>
CSS:
.gon {
width: 220px;
height: 220px;
background: darkblue;
background-size: 220px 220px;
/* Text styling */
line-height: 220px;
text-align: center;
font-family: sans-serif;
font-size: 15px;
font-weight: bold;
letter-spacing: 6px;
color: beige;
}
.gon:hover {
color: #fff;
text-shadow: 0 0 10px white;
}
.buttoncut {
height: 200px;
-webkit-clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%);
-moz-clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%);
-ms-clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%);
clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%); clip-path: polygon(0% 0%, 100% 0, 100% 50%, 60% 100%, 0% 100%);
}
I used this generator to get the correct polygon css: http://bennettfeely.com/clippy/
Gradients:
You could use gradients in order to achieve this, and that way you can apply it to any element (this one's done with a button element):
html,body{
background:red;
}
button {
background: -moz-linear-gradient(-45deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, right bottom, color-stop(0%, rgba(30, 87, 153, 1)), color-stop(89%, rgba(30, 87, 153, 1)), color-stop(90%, rgba(30, 87, 153, 0)), color-stop(100%, rgba(30, 87, 153, 0)));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(-45deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(-45deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(-45deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* IE10+ */
background: linear-gradient(135deg, rgba(30, 87, 153, 1) 0%, rgba(30, 87, 153, 1) 89%, rgba(30, 87, 153, 0) 90%, rgba(30, 87, 153, 0) 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1e5799', endColorstr='#001e5799', GradientType=1);
/* IE6-9 fallback on horizontal gradient */
outline:0;
border:0;
padding:5px;
}
<button>PressMe</button>
Pseudo Element (not great for gradient/image backgrounds)
div {
position: relative;
display:inline-block;
padding:5px;
background:gray;
}
div:after{
content:"";
position:absolute;
border-bottom:10px solid blue;
border-left:10px solid transparent;
bottom:0;
right:0;
}
html,body{
background:blue;
}
<div>Press Me!</div>
Clip Path
button {
padding: 10px;
height: 60px;
width: 60px;
-webkit-clip-path: polygon(0% 0%, 100% 0, 100% 75%, 75% 100%, 0% 100%);
clip-path: polygon(0% 0%, 100% 0, 100% 75%, 75% 100%, 0% 100%);
}
html,body{
background:green;
}
<button>press me!!!</button>
Dynamic length
by using the following snippet, you can make a great button, which isn't affected by length!
button {
position: relative;
border: 0;
outline: 0;
height: 20px;
background: gray;
}
button:after {
position: absolute;
content: "";
right: -10px;
width: 0px;
height: 0px;
bottom: 0;
border-bottom: 10px solid transparent;
border-left: 10px solid gray;
}
button:before {
position: absolute;
content: "";
right: -10px;
width: 10px;
height: 10px;
top: 0;
background: gray;
}
html,
body {
background: red;
}
/*HOVER EFFECTS*/
button:hover,
button:hover:before {
background: yellow;
}
button:hover:after {
border-left: 10px solid yellow;
}
<button>press me and plus i can get really long!</button>