I'm trying to combine the look of one button, with the responsiveness of another button:
Button A: https://codepen.io/vitor-siqueira/pen/xNBExN
Button B: https://codepen.io/AnthonyBmm/pen/poooJmO
I would like to make Button C, which looks and feels exactly like Button A, but it automagically resizes to fit the button text (no wrap, like Button B). At the moment I create 3-4 virtually identical Button A's and adjust the width values of the SVG and the CSS, which... is terrible practice.
I found Button B which has a similar animation but without an SVG and thought that it may be a good start to try and replicate the Button A effect, but I haven't been able to succeed.
Can someone help please?
The attached code from the 2 pens can be found below:
Button A HTML:
<div class="container">
<div class="center">
<button class="btn">
<svg width="180px" height="60px" viewBox="0 0 180 60" class="border">
<polyline points="179,1 179,59 1,59 1,1 179,1" class="bg-line" />
<polyline points="179,1 179,59 1,59 1,1 179,1" class="hl-line" />
</svg>
<span>HOVER ME</span>
</button>
</div>
</div>
Button A CSS:
#import url('https://fonts.googleapis.com/css?family=Lato:100&display=swap');
body, html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #5CA4EA;
overflow: hidden;
font-family: 'Lato', sans-serif;
}
.container {
width: 400px;
height: 400px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
}
.center {
width: 180px;
height: 60px;
position: absolute;
}
.btn {
width: 180px;
height: 60px;
cursor: pointer;
background: transparent;
border: 1px solid #91C9FF;
outline: none;
transition: 1s ease-in-out;
}
svg {
position: absolute;
left: 0;
top: 0;
fill: none;
stroke: #fff;
stroke-dasharray: 150 480;
stroke-dashoffset: 150;
transition: 1s ease-in-out;
}
.btn:hover {
transition: 1s ease-in-out;
background: #4F95DA;
}
.btn:hover svg {
stroke-dashoffset: -480;
}
.btn span {
color: white;
font-size: 18px;
font-weight: 100;
}
Button B HTML:
<body>
<a href="#">push this and that
<span></span>
<span></span>
<span></span>
<span></span>
</a>
</body>
Button B CSS:
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #999;
}
a {
/*border-radius: 12px;*/
border: 3px outset #888;
position: relative;
display: inline-block;
padding: 15px 30px;
color: #eee;
text-transform: uppercase;
letter-spacing: 4px;
overflow: hidden;
box-shadow: 0 0 10px rgb(0, 0, 0, 1);
font-family: verdana;
font-size: 28px;
font-weight: bolder;
text-decoration: none;
background:linear-gradient(160deg, #666, #444);
text-shadow: 0px 0px 2px rgba(0, 0, 0, .5);
transition: 0.2s;
}
a:active {
border: 3px outset #ddd;
color: #fff;
background: linear-gradient(160deg, #666, #444);
text-shadow: 0px 0px 4px #ccc;
box-shadow: 0 0 10px #fff, 0 0 40px #fff, 0 0 80px #fff;
transition-delay: 1s;
}
a span {
position: absolute;
display: block;
}
a span:nth-child(1) {
top: 0;
left: -100%;
width: 100%;
height: 2px;
background: linear-gradient(90deg, transparent, #eee);
}
a:active span:nth-child(1) {
left: 100%;
transition: 1s;
}
a span:nth-child(2) {
top: -100%;
right: 0;
width: 2px;
height: 100%;
background: linear-gradient(180deg, transparent, #eee);
}
a:active span:nth-child(2) {
top: 100%;
transition: 1s;
transition-delay: 0.25s;
}
a span:nth-child(3) {
bottom: 0;
right: -100%;
width: 100%;
height: 2px;
background: linear-gradient(270deg, transparent, #eee);
}
a:active span:nth-child(3) {
right: 100%;
transition: 1s;
transition-delay: 0.5s;
}
a span:nth-child(4) {
bottom: -100%;
left: 0;
width: 2px;
height: 100%;
background: linear-gradient(360deg, transparent, #eee);
}
a:active span:nth-child(4) {
bottom: 100%;
transition: 1s;
transition-delay: 0.75s;
}
Is this what you are looking for?
#import url('https://fonts.googleapis.com/css?family=Lato:100&display=swap');
body, html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #5CA4EA;
overflow: hidden;
font-family: 'Lato', sans-serif;
}
.container {
width: 400px;
height: 400px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
}
.center {
width: 180px;
height: 60px;
position: absolute;
}
.btn {
width: 180px;
height: 60px;
cursor: pointer;
background: transparent;
border: 1px solid #91C9FF;
outline: none;
transition: 1s ease-in-out;
}
svg {
position: absolute;
left: 0;
top: 0;
fill: none;
stroke: #fff;
stroke-dasharray: 150 480;
stroke-dashoffset: 150;
transition: 1s ease-in-out;
}
.btn:hover {
transition: 1s ease-in-out;
background: #4F95DA;
}
.btn:hover svg {
stroke-dashoffset: -480;
}
.btn span {
color: white;
font-size: 18px;
font-weight: 100;
}
button:active {
border: 3px outset #ddd;
color: #fff;
background: linear-gradient(160deg, #666, #444);
text-shadow: 0px 0px 4px #ccc;
box-shadow: 0 0 10px #fff, 0 0 40px #fff, 0 0 80px #fff;
transition-delay: 1s;
}
<div class="container">
<div class="center">
<button class="btn">
<svg width="180px" height="60px" viewBox="0 0 180 60" class="border">
<polyline points="179,1 179,59 1,59 1,1 179,1" class="bg-line" />
<polyline points="179,1 179,59 1,59 1,1 179,1" class="hl-line" />
</svg>
<span>HOVER ME</span>
</button>
</div>
</div>
This "Correction" of mine was based on the post this post to make svg responsible.
Sorry for the english of google translator.
#import url('https://fonts.googleapis.com/css?family=Lato:100&display=swap');
body, html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #5CA4EA;
overflow: hidden;
font-family: 'Lato', sans-serif;
}
.container {
width: 400px;
height: 400px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
}
.btn {
cursor: pointer;
background: transparent;
border: 1px solid #91C9FF;
outline: none;
transition: 1s ease-in-out;
padding:3%;
padding-top:2%;
padding-bottom:2%;
position: relative;
display: flex;
}
svg {
width: calc(100% + 2px);
height: calc(100% + 2px);
position: absolute;
left: -1px;
top: -1px;
fill: none;
stroke: #fff;
stroke-dasharray: 150 480;
stroke-dashoffset: 150;
transition: 1s ease-in-out;
}
.btn:hover {
transition: 1s ease-in-out;
background: #4F95DA;
}
.btn:hover svg {
stroke-dashoffset: -480;
}
.bg-line{
width:100px;
height:100px;
}
.btn span {
color: white;
font-size: 18px;
font-weight: 100;
}
<div class="container">
<button class="btn">
<!-- edit -->
<svg viewBox="0 0 180 60" class="border" preserveAspectRatio="none" class="border">
<polyline points="179,1 179,59 1,59 1,1 179,1" class="bg-line" />
<polyline points="179,1 179,59 1,59 1,1 179,1" class="hl-line" />
</svg>
<span>Junior is AWESOME</span>
</button>
</div>
OR
I really wanted to find a more correct way to do this without using SVG, I researched it all day, this is what I got:
I used the Animation, Before and Linear-gradient properties. The animation is not fluid because I'm not really good at it, and above all I recommend using a file just for keyframes.
(The "back" animation can be included later: D)
English from google translator
#import url('https://fonts.googleapis.com/css?family=Lato:100&display=swap');
body, html {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: #5CA4EA;
overflow: hidden;
font-family: 'Lato', sans-serif;
}
.container {
width: 400px;
height: 400px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
display: flex;
justify-content: center;
align-items: center;
}
.btn {
cursor: pointer;
background: rgb(99, 169, 235);
border: 1px solid #91C9FF;
outline: none;
transition: 1s ease-in-out;
padding:3%;
padding-top:2%;
padding-bottom:2%;
position: relative;
display: flex;
}
.btn::before {
content: '';
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
z-index: -1;
margin: -3px; /* !importanté */
border-radius: inherit; /* !importanté */
background: linear-gradient(0deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0) 99%, rgba(255,255,255,0) 100%);
}
.btn:hover::before{
-webkit-animation: all 1s; /* Chrome, Safari, Opera */
animation: all 1s;
transition:animation 1s ease-in-out;
}
#keyframes all {
2% {
background: linear-gradient(-45deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.3) 99%, rgba(255,255,255,0) 100%);
}
5% {
background: linear-gradient(-45deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.5) 99%, rgba(255,255,255,0) 100%);
}
7% {
background: linear-gradient(-45deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
14% {
background: linear-gradient(-23deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
22% {
background: linear-gradient(0deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
28% {
background: linear-gradient(23deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
35% {
background: linear-gradient(45deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
43% {
background: linear-gradient(90deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
50% {
background: linear-gradient(120deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
57% {
background: linear-gradient(145deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
64% {
background: linear-gradient(180deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
71% {
background: linear-gradient(200deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
78% {
background: linear-gradient(220deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
85% {
background: linear-gradient(300deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
92% {
background: linear-gradient(320deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
94% {
background: linear-gradient(345deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.9) 99%, rgba(255,255,255,0) 100%);
}
97% {
background: linear-gradient(345deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.5) 99%, rgba(255,255,255,0) 100%);
}
100% {
background: linear-gradient(345deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.3) 99%, rgba(255,255,255,0) 100%);
}
}
/* Chrome, Safari, Opera */
#-webkit-keyframes all {
2% {
background: linear-gradient(-45deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.3) 99%, rgba(255,255,255,0) 100%);
}
5% {
background: linear-gradient(-45deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.5) 99%, rgba(255,255,255,0) 100%);
}
7% {
background: linear-gradient(-45deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
14% {
background: linear-gradient(-23deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
22% {
background: linear-gradient(0deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
28% {
background: linear-gradient(23deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
35% {
background: linear-gradient(45deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
43% {
background: linear-gradient(90deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
50% {
background: linear-gradient(120deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
57% {
background: linear-gradient(145deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
64% {
background: linear-gradient(180deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
71% {
background: linear-gradient(200deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
78% {
background: linear-gradient(220deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
85% {
background: linear-gradient(300deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
92% {
background: linear-gradient(320deg, rgba(255,255,255,0) 72%, rgba(255,255,255,1) 99%, rgba(255,255,255,0) 100%);
}
94% {
background: linear-gradient(345deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.9) 99%, rgba(255,255,255,0) 100%);
}
97% {
background: linear-gradient(345deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.5) 99%, rgba(255,255,255,0) 100%);
}
100% {
background: linear-gradient(345deg, rgba(255,255,255,0) 72%, rgba(255,255,255,0.3) 99%, rgba(255,255,255,0) 100%);
}
}
.btn:hover {
transition: 1s ease-in-out;
background: #4F95DA;
}
.btn:hover svg {
stroke-dashoffset: -480;
}
.bg-line{
width:100px;
height:100px;
}
.btn span {
color: white;
font-size: 18px;
font-weight: 100;
}
<div class="container">
<button class="btn">
<!-- edit -->
<span>Junior is AWESOME</span>
</button>
</div>
I'm working on a ticket shape div, my problem is that I can't move the circles to the position I want.
I'm following this code:
* {
box-sizing: border-box;
}
body {
padding: 2em;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-align: center;
background-color: #ff4500;
-webkit-animation: bg 10s linear infinite alternate;
animation: bg 10s linear infinite alternate;
color: rgba(0, 0, 0, 0.25);
font-size: 13px;
}
a {
color: rgba(0, 0, 0, 0.35);
}
.ticket {
display: inline-block;
box-sizing: content-box;
-webkit-filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
position: relative;
height: 1em;
padding: 1em;
color: #000;
font-size: 16px;
background-size: 51% 100%;
background-repeat: no-repeat;
background-image: radial-gradient(circle at 0 50%, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em), radial-gradient(circle at 100% 50%, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em);
background-position: top left, top right;
}
#-webkit-keyframes bg {
0% {
background-color: #ff4500;
}
50% {
background-color: #b0e0e6;
}
100% {
background-color: #ff4500;
}
}
#keyframes bg {
0% {
background-color: #ff4500;
}
50% {
background-color: #b0e0e6;
}
100% {
background-color: #ff4500;
}
}
<span class="ticket">Ticket shape with transparent holes punched!</span>
<br />
<br />
<p>Based on Lea Verou's faux inset border-radius technique.</p>
What I want is move the circles to the top left and bottom left of the div.
The problem
The problem is that the first background is being displayed over the top of the second background, you can move the position of the circle but it is hidden.
To fix
You can achieve this by making the following changes:
background-size: 51% 100%; to background-size: 100% 50%; to make the background take up half of the height instead of the width
background-position: top left, top right; to background-position: top left, bottom left; to position the backgrounds at the top and bottom
background-image: radial-gradient(circle at 0 50%, rgba(255,255,224,0) 0.4em, #ffffe0 0.5em), radial-gradient(circle at 100% 50%, rgba(255,255,224,0) 0.4em, #ffffe0 0.5em); to background-image: radial-gradient(circle at 0 0, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em), radial-gradient(circle at 0 100%, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em); to position the radial gradient at the top and bottom of the backgrounds
* {
box-sizing: border-box;
}
body {
padding: 2em;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-align: center;
background-color: #ff4500;
-webkit-animation: bg 10s linear infinite alternate;
animation: bg 10s linear infinite alternate;
color: rgba(0, 0, 0, 0.25);
font-size: 13px;
}
a {
color: rgba(0, 0, 0, 0.35);
}
.ticket {
display: inline-block;
box-sizing: content-box;
-webkit-filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
position: relative;
height: 1em;
padding: 1em;
color: #000;
font-size: 16px;
background-size: 100% 50%;
background-repeat: no-repeat;
background-image: radial-gradient(circle at 0 0, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em), radial-gradient(circle at 0 100%, rgba(255, 255, 224, 0) 0.4em, #ffffe0 0.5em);
background-position: top left, bottom left;
}
#-webkit-keyframes bg {
0% {
background-color: #ff4500;
}
50% {
background-color: #b0e0e6;
}
100% {
background-color: #ff4500;
}
}
#keyframes bg {
0% {
background-color: #ff4500;
}
50% {
background-color: #b0e0e6;
}
100% {
background-color: #ff4500;
}
}
<span class="ticket">Ticket shape with transparent holes punched!</span>
<br />
<br />
<p>Based on Lea Verou's faux inset border-radius technique.</p>
you can use the below property for positioning change.
background-image radial-gradient(circle at 0 50%, rgba($bg,0) $hole, $bg ($hole + .1em)), radial-gradient(circle at 100% 50%, rgba($bg,0) $hole, $bg ($hole + .1em))
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>