How to make a button with an obtuse angle? - html

how to make a button with an obtuse angle?
I would like to happen like this
I got here so
My code - Fiddle
*{
box-sizing: border-box;
}
.btn{
display: inline-block;
padding: 16px 30px;
color: #fff;
border: 1px solid #4A803C;
position: relative;
border-radius: 3px;
background: rgb(74,168,28); /* Old browsers */
background: -moz-linear-gradient(top, rgba(74,168,28,1) 0%, rgba(63,155,19,1) 100%, rgba(56,146,12,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(74,168,28,1) 0%,rgba(63,155,19,1) 100%,rgba(56,146,12,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(74,168,28,1) 0%,rgba(63,155,19,1) 100%,rgba(56,146,12,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4aa81c', endColorstr='#38920c',GradientType=0 );
}
.btn > span{
position:relative;
z-index: 1;
}
.btn:after {
content: "";
width: 35px;
height: 35px;
display: block;
position: absolute;
top: 7px;
right: -18px;
border: 1px solid #4A803C;
border-left: none;
border-bottom: none;
border-radius: 3px;
-webkit-transform: rotate(47deg) skew(5deg);
transform: rotate(47deg) skew(5deg);
background-image: -moz-linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -webkit-linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -ms-linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: linear-gradient( 143deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
}
.btn:hover{
background: rgb(56,146,12); /* Old browsers */
background: -moz-linear-gradient(top, rgba(56,146,12,1) 0%, rgba(63,155,19,1) 0%, rgba(74,168,28,1) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(56,146,12,1) 0%,rgba(63,155,19,1) 0%,rgba(74,168,28,1) 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(56,146,12,1) 0%,rgba(63,155,19,1) 0%,rgba(74,168,28,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#38920c', endColorstr='#4aa81c',GradientType=0 );
}
.btn:hover:after{
background-image: -moz-linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -webkit-linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: -ms-linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
background-image: linear-gradient( -47deg, rgb(74,168,28) 0%, rgb(63,155,19) 100%);
}
<a href="#" class="btn">
<span>Умножитель матрицы</span>
</a>
I would be glad of any help.
Thank you

A simple solution would be to add a rotateY(Xdeg) to the .btn:after element. This would make the element's Y-axis get rotated and thus would make it look narrower than it actually is.
Rotation angle can be modified as required. It can be any value below 90 degrees depending on how wide or narrow the arrow should be. Higher the value the narrower the arrow would be.
* {
box-sizing: border-box;
}
.btn {
display: inline-block;
padding: 16px 30px;
color: #fff;
border: 1px solid #4A803C;
position: relative;
border-radius: 3px;
background: rgb(74, 168, 28);
background: linear-gradient(to bottom, rgba(74, 168, 28, 1) 0%, rgba(63, 155, 19, 1) 100%, rgba(56, 146, 12, 1) 100%);
}
.btn > span {
position: relative;
z-index: 1;
}
.btn:after {
content: "";
width: 35px;
height: 35px;
display: block;
position: absolute;
top: 7px;
right: -18px;
border: 1px solid #4A803C;
border-left: none;
border-bottom: none;
border-radius: 3px;
transform: rotateY(45deg) rotate(47deg) skew(5deg);
background-image: linear-gradient(143deg, rgb(74, 168, 28) 0%, rgb(63, 155, 19) 100%);
}
.btn:hover {
background: rgb(56, 146, 12);
background: linear-gradient(to bottom, rgba(56, 146, 12, 1) 0%, rgba(63, 155, 19, 1) 0%, rgba(74, 168, 28, 1) 100%);
}
.btn:hover:after {
background-image: linear-gradient(-47deg, rgb(74, 168, 28) 0%, rgb(63, 155, 19) 100%);
}
<a href="#" class="btn">
<span>Умножитель матрицы</span>
</a>

Related

Unsure how to position image over gradient correctly

I am generating a gradient on the page. How can I overlay an image in the center of this ribbon? I need to center the image and I cant seem to figure out how to make this work. I am using bootstrap and the page is responsive. So it needs to stay together when the page gets smaller. Any help is appreciated!
Desired Result:
#ribbon-background {
background: #ed1c24; /* Old browsers */
background: -moz-linear-gradient(left, #ed1c24 0%, #600000 50%, #ed1c24 100%); /* FF3.6-15 */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#ed1c24), color-stop(50%,#600000), color-stop(100%,#ed1c24)); /* Chrome4-9,Safari4-5 */
background: -webkit-linear-gradient(left, #ed1c24 0%,#600000 50%,#ed1c24 100%); /* Chrome10-25,Safari5.1-6 */
background: -o-linear-gradient(left, #ed1c24 0%,#600000 50%,#ed1c24 100%); /* Opera 11.10-11.50 */
background: -ms-linear-gradient(left, #ed1c24 0%,#600000 50%,#ed1c24 100%); /* IE10 preview */
background: linear-gradient(to right, #ed1c24 0%,#600000 50%,#ed1c24 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ed1c24', endColorstr='#ed1c24',GradientType=1 ); /* IE6-9 */
border-top: 3px solid #000;
border-bottom: 3px solid #000;
box-shadow: 0 7px 0 #FFF inset,
0 -7px 0 #FFF inset;
height: 65px;
margin: 0 auto;
width: 100%;
z-index: 99;
}
<div id="ribbon-background"></div>
One way to do that is to give the ribbon a position: relative; and add the follow style to a child <img>:
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
Demo:
#ribbon-background {
background: #ed1c24;
/* Old browsers */
background: -moz-linear-gradient(left, #ed1c24 0%, #600000 50%, #ed1c24 100%);
/* FF3.6-15 */
background: -webkit-gradient(linear, left top, right top, color-stop(0%, #ed1c24), color-stop(50%, #600000), color-stop(100%, #ed1c24));
/* Chrome4-9,Safari4-5 */
background: -webkit-linear-gradient(left, #ed1c24 0%, #600000 50%, #ed1c24 100%);
/* Chrome10-25,Safari5.1-6 */
background: -o-linear-gradient(left, #ed1c24 0%, #600000 50%, #ed1c24 100%);
/* Opera 11.10-11.50 */
background: -ms-linear-gradient(left, #ed1c24 0%, #600000 50%, #ed1c24 100%);
/* IE10 preview */
background: linear-gradient(to right, #ed1c24 0%, #600000 50%, #ed1c24 100%);
/* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ed1c24', endColorstr='#ed1c24', GradientType=1);
/* IE6-9 */
border-top: 3px solid #000;
border-bottom: 3px solid #000;
box-shadow: 0 7px 0 #FFF inset, 0 -7px 0 #FFF inset;
height: 65px;
margin: 0 auto;
width: 100%;
z-index: 99;
position: relative;
}
#ribbon-overlay-img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<div id="ribbon-background">
<img id="ribbon-overlay-img" src="http://www.iconsdb.com/icons/preview/orange/stackoverflow-4-xxl.png">
</div>

Create a glossy light effect using CSS

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);
}

How can I make a nice yellow button with text shadow?

I almost have a nice blue button but I want the background yellow and I want the text in center.
#post3 {
width: 450px;
background: -moz-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #6db3f2), color-stop(50%, #54a3ee), color-stop(51%, #3690f0), color-stop(100%, #1e69de)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* IE10+ */
background: linear-gradient(to bottom, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#6db3f2', endColorstr='#1e69de', GradientType=0); /* IE6-9 */
/*display: inline-block;*/
border: 1px solid rgb(0, 0, 0);
/*width: 290px;*/
height: 45px;/*
font-size: 150%;*/
text-decoration: none;
/*text-align: center;*/
color: rgb(255, 255, 255);
font-weight: bold;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
background-image: -webkit-linear-gradient(top, rgb(109, 179, 242) 0%, rgb(84, 163, 238) 50%, rgb(54, 144, 240) 51%, rgb(30, 105, 222) 100%);
background-position: initial initial;
background-repeat: initial initial;
}
<div id="post3"> Loren Ipsum</div>
Can you please help me? I don't know how to center the text and I don't know how to apply a text shadow.
Check this out:
Demo
background-image: -webkit-linear-gradient(top, rgb(242, 227, 109) 0%, rgb(219, 238, 84) 50%, rgb(240, 231, 54) 51%, rgb(222, 222, 30) 100%);
width:450px; /*It was width=450px; */
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<style>
#post3 {
background: #ffcf32; /* Old browsers */
background: -moz-linear-gradient(top, #ffcf32 0%, #ffff30 50%, #f7df27 51%, #ffdf89 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffcf32), color-stop(50%,#ffff30), color-stop(51%,#f7df27), color-stop(100%,#ffdf89)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffcf32 0%,#ffff30 50%,#f7df27 51%,#ffdf89 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffcf32 0%,#ffff30 50%,#f7df27 51%,#ffdf89 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffcf32 0%,#ffff30 50%,#f7df27 51%,#ffdf89 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffcf32 0%,#ffff30 50%,#f7df27 51%,#ffdf89 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffcf32', endColorstr='#ffdf89',GradientType=0 ); /* IE6-9 */
/*display: inline-block;*/
border: 1px solid rgb(0, 0, 0);
/*width: 290px;*/
height: 45px;/*
font-size: 150%;*/
text-decoration: none;
/*text-align: center;*/
font-weight: bold;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
background-image: -webkit-linear-gradient(top, rgb(109, 179, 242) 0%, rgb(84, 163, 238) 50%, rgb(54, 144, 240) 51%, rgb(30, 105, 222) 100%);
background-position: initial initial;
background-repeat: initial initial;
width: 300px;
text-align: center;
}
span.center-content {
display: inline-block;
vertical-align: middle;
line-height:45px;
}
#post3 a {
color: #fff;
font-size: 24px;
letter-spacing: 2px;
text-decoration: none;
text-shadow: 2px 3px 7px #000000;
text-transform: uppercase;
}
</style>
</head>
<body>
<div id="post3"><span class="center-content">Loren Ipsum</span></div>
</body>
</html>
Just copy and paste the code above you should see the yellow colored button with gradient effect. Have a look at the URL http://www.colorzilla.com/gradient-editor/#ffcf32+0,ffff30+50,f7df27+51,ffdf89+100;Custom for creating the gradients on the fly.
This code coveres
Yellow gradient
Horizontally and vertically centered text
Shadow effect for the text on the button

CSS issue with background button [duplicate]

This question already has answers here:
How do I combine a background-image and CSS3 gradient on the same element?
(20 answers)
Closed 8 years ago.
I have a button, that has a gradient on it. I also needs an image arrow on it, but when I put it to background, and a button with two classes it seems not to work. Below is an example:
<button class="btn btn-wide">Load more</button>
.btn{
background: rgb(0,166,255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(0,166,255,1) 0%, rgba(0,166,255,1) 50%, rgba(2,154,236,1) 53%, rgba(2,154,236,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,166,255,1)), color-stop(50%,rgba(0,166,255,1)), color-stop(53%,rgba(2,154,236,1)), color-stop(100%,rgba(2,154,236,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00a6ff', endColorstr='#029aec',GradientType=0 ); /* IE6-9 */
border:0px;
color:white;
font-family: HelveticaNarrow;
font-weight: bold;
font-size: 12pt;
text-transform: uppercase;
cursor: pointer;
}
.btn-wide{
width:728px;
height:45px;
background-image: url('images/white-arrow-down.png') no-repeat;
background-position: 50% 50%;
}
The background at the class .btn-wide is getting ignored because of the .btn class I guess.
What would be the best markup solution in this example? :)
Jsfiddle
The issue is that you are using the background shorthand property so trying to apply a second background image merely overwrites the previous statement (the gradient).
You can use comma separated background image statements like this.
CSS
.btn{
background-image: /* note bg image */
url(http://lorempixel.com/output/abstract-q-c-32-32-2.jpg),
linear-gradient(to bottom, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* W3C */
background-repeat:no-repeat;
border:0px;
color:white;
font-family: HelveticaNarrow;
font-weight: bold;
font-size: 12pt;
text-transform: uppercase;
cursor: pointer;
background-position:50% 50%;
}
.btn-wide{
width:728px;
height:45px;
}
JSFiddle Demo
Find the following link for updated fiddle.
FIDDLE
I updated the css.
.btn{
background: rgb(0,166,255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(0,166,255,1) 0%, rgba(0,166,255,1) 50%, rgba(2,154,236,1) 53%, rgba(2,154,236,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,166,255,1)), color-stop(50%,rgba(0,166,255,1)), color-stop(53%,rgba(2,154,236,1)), color-stop(100%,rgba(2,154,236,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0,166,255,1) 0%,rgba(0,166,255,1) 50%,rgba(2,154,236,1) 53%,rgba(2,154,236,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00a6ff', endColorstr='#029aec',GradientType=0 ); /* IE6-9 */
border:0px;
color:white;
font-family: HelveticaNarrow;
font-weight: bold;
font-size: 12pt;
text-transform: uppercase;
cursor: pointer;
position:relative;
width:728px;
height:45px;
}
.btn div{
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background-image: url('https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-ios7-arrow-right-128.png');
background-position: right;
background-repeat:no-repeat;
background-size:32px 32px;
}
Change the arrow image path according to your image.
The problem is with this rule
background-image: url('images/white-arrow-down.png') no-repeat;
you're specifying repeat in background-image.
You can rewrite it as
background-image: url('images/white-arrow-down.png');
background-repeat: no-repeat;
Update:
Fixing actual issue in your CSS doesn't provide you with your desired results because backgorund-image is going to overwrite the gradient. You can add position: relative .btn, remove background from .btn-wide, and use :before pseudo selector to add an element to your button. Following is the CSS
.btn{
background: rgb(0, 166, 255); /* Old browsers */
background: -moz-linear-gradient(top, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0, 166, 255, 1)), color-stop(50%, rgba(0, 166, 255, 1)), color-stop(53%, rgba(2, 154, 236, 1)), color-stop(100%, rgba(2, 154, 236, 1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(0, 166, 255, 1) 0%, rgba(0, 166, 255, 1) 50%, rgba(2, 154, 236, 1) 53%, rgba(2, 154, 236, 1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00a6ff', endColorstr='#029aec', GradientType=0); /* IE6-9 */
border: 0px;
color: white;
font-family: HelveticaNarrow;
font-weight: bold;
font-size: 12pt;
text-transform: uppercase;
cursor: pointer;
position: relative;;
}
.btn-wide{
width: 728px;
height: 45px;
}
.btn-wide:before{
content: ' ';
display: block;
height: 100%;
width: 100%;
position: absolute;
background: url('images/white-arrow-down.png') no-repeat 50% 50%;
top: 0;
left: 0;
}

How to reverse a CSS animation on unchecked state?

My project will display a sunny field and a check box that says "make it rain". Upon clicking the button the sun sets, and clouds come in, and there will be animated CSS rain. I'm using a checked pseudo class to start the rain animation and the rotation of the sun.
How can I reverse the animation for the unchecked state?
The order the page should work in is as follows:
Page loads, default unchecked state of button, sun should be up
User clicks button, pseudo class:checked gets activated and the animation starts
User clicks button again, thus unchecking the button and the animation should reverse to it's original state.
Right now, it just resets the whole page when the button gets unchecked. Is there a way to reverse the animation to it's original state without using any JavaScript? This project is CSS only.
.sky {
height: 70%;
width: 100%;
position: absolute;
z-index: 1;
background: #e4f5fc;
/* Old browsers */
background: -moz-linear-gradient(top, #e4f5fc 0%, #bfe8f9 33%, #9fd8ef 86%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #e4f5fc), color-stop(33%, #bfe8f9), color-stop(86%, #9fd8ef));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #e4f5fc 0%, #bfe8f9 33%, #9fd8ef 86%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #e4f5fc 0%, #bfe8f9 33%, #9fd8ef 86%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, #e4f5fc 0%, #bfe8f9 33%, #9fd8ef 86%);
/* IE10+ */
background: linear-gradient(to bottom, #e4f5fc 0%, #bfe8f9 33%, #9fd8ef 86%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e4f5fc', endColorstr='#9fd8ef', GradientType=0);
/* IE6-9 */
}
.rainsun {
position: absolute;
margin: 35px 45%;
width: 15.74803%;
/*--300px--*/
color: white;
text-align: center;
text-shadow: 0 1px 0 rgba(0, 0, 0, .5);
font-size: 2.5em;
cursor: pointer;
z-index: 5;
}
.rainsun:after {
position: absolute;
display: block;
padding: 10px 0;
width: 100%;
/*--300px--*/
border: 1px solid #76011b;
border-radius: 8px;
background: linear-gradient(to bottom, rgba(169, 3, 41, 1) 0%, rgba(143, 2, 34, 1) 44%, rgba(109, 0, 25, 1) 100%);
box-shadow: 0px 0px 10px rgba(19, 93, 158, .6);
content: "Make it Rain";
z-index: 5;
}
.rainsun:checked:after {
background: linear-gradient(to bottom, rgba(109, 0, 25, 1) 0%, rgba(143, 2, 34, 1) 61%, rgba(169, 3, 41, 1) 100%);
content: "Make it Shine";
}
.sun_path {
border: 1px dashed black;
width: 44.094488%;
height: 100%;
position: absolute;
z-index: 2;
border-radius: 50%;
margin-left: 10%;
margin-top: 10%;
}
.sun {
width: 30%;
height: 30%;
background-color: yellow;
border: 8px solid orange;
border-radius: 50%;
box-shadow: 0 0 128px red;
margin: auto;
margin-top: -15%;
}
.grass {
height: 30%;
width: 100%;
position: absolute;
bottom: 0;
z-index: 3;
background: #9dd53a;
/* Old browsers */
background: -moz-linear-gradient(top, #9dd53a 0%, #a1d54f 23%, #80c217 70%, #7cbc0a 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #9dd53a), color-stop(23%, #a1d54f), color-stop(70%, #80c217), color-stop(100%, #7cbc0a));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #9dd53a 0%, #a1d54f 23%, #80c217 70%, #7cbc0a 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #9dd53a 0%, #a1d54f 23%, #80c217 70%, #7cbc0a 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, #9dd53a 0%, #a1d54f 23%, #80c217 70%, #7cbc0a 100%);
/* IE10+ */
background: linear-gradient(to bottom, #9dd53a 0%, #a1d54f 23%, #80c217 70%, #7cbc0a 100%);
/* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9dd53a', endColorstr='#7cbc0a', GradientType=0);
/* IE6-9 */
}
/*animations*/
.rainsun:checked~.sun_path {
-webkit-animation: spin-right 3s 1 forwards;
-moz-animation: spin-right 3s 1 forwards;
animation: spin-right 3s 1 forwards;
}
/* keyframes */
#-webkit-keyframes spin-right {
100% {
-webkit-transform: rotate(180deg);
}
}
#-moz-keyframes spin-right {
100% {
-webkit-transform: rotate(180deg);
}
}
<input class="rainsun" type="checkbox">
<div class="sky">
</div>
<!--end sky-->
<div class="sun_path">
<div class="sun"></div>
</div>
<!--end sun_path-->
<div class="grass">
</div>
<!--end grass-->
Instead of using keyframes, try a transform and set transition: transform. Here's an example of what I'm talking about:
.rainsun ~ .sun_path {
-webkit-transition: -webkit-transform 3s;
-moz-transition: -moz-transform 3s;
transition: transform 3s;
}
.rainsun:checked ~ .sun_path {
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
transform: rotate(180deg);
}
Codepen Fork: Demo