Filters and background images together - css

I'm trying to create a gradient effect for a button that degrades "Gracefully" on IE8 & IE9. I've a glossy gradient button, What I've done is that to get the same glossy look and feel in IE9 I'm using an SVG background image. For IE8 I've decided to loose the gloss and just stick to the basic two stops gradient the problem is that as soon as I ad the filter it take preference over background in IE9 as well which I don't want to happen. Is there a workaround for this issue? Following is the CSS
input[type="button"], input[type="submit"], input[type="reset"], button {
padding: 3px 10px 3px 10px;
margin: 0;
border: none;
color: white;
outline: 0;
font-size: 0.875em;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
overflow: visible;
width: auto;
background: #094fa4;
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#009ee5', endColorstr='#094fa4',GradientType=0 );
background-image: url(../images/btn.svg);
background: -moz-linear-gradient(top, #2261ad 0%, #2261ad 50%, #094fa4 50%, #094fa4 100%);
background: -webkit-linear-gradient(top, #2261ad 0%, #2261ad 50%, #094fa4 50%, #094fa4 100%);
background: -ms-linear-gradient(top, #2261ad 0%, #2261ad 50%, #094fa4 50%, #094fa4 100%);
/*background:linear-gradient(to bottom, #2261ad 0%, #2261ad 50%, #094fa4 50%, #094fa4 100%);*/
border-top: 1px solid #4379B9;
border-bottom: 1px solid #08438C;
border-radius: 4px;
cursor: pointer;
}

You can use CSS hack for IE8. Write like this:
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#009ee5', endColorstr='#094fa4',GradientType=0 )\9; //for IE8 & below.
background-image: url(../images/btn.svg);
Read this for more http://www.gravitationalfx.com/css-hacks-for-ie-targeting-only-ie8-ie7-and-ie6/
OR
You can use conditional comment for different browsers http://www.quirksmode.org/css/condcom.html

Related

Disabled button not being styled correctly

I am trying to style a button that is disabled, but the styling doesn't take effect, and go back to the old styling. I have cleared my cache, to no avail. I have a button that gets disabled using JavaScript with document.getElementById("updateAccountButton").disabled = true;. This aforementioned button also has the class of btn-signature-green. Inside my stylesheet, I am trying to set the styling of this button when disabled using:
.btn-signature-blue:disabled, .btn-signature-green:disabled, .btn-signature-red:disabled {
/* styles go here */
}
This is because I have other buttons that may have disabled attributes that I want to account for.
Code snippet:
$(window).on("load", function() {
document.getElementById("updateAccountButton").disabled = true;
});
/* disabled button */
.btn-signature-blue:disabled, .btn-signature-green:disabled, .btn-signature-red:disabled {
background-color: #afafaf;
color: white;
}
.btn-signature-green {
-moz-box-shadow: 0px 6px 11px -7px #5fd623;
-webkit-box-shadow: 0px 6px 11px -7px #5fd623;
box-shadow: 0px 6px 11px -7px #5fd623;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #67e827), color-stop(1, #81de52));
background: -moz-linear-gradient(top, #67e827 5%, #81de52 100%);
background: -webkit-linear-gradient(top, #67e827 5%, #81de52 100%);
background: -o-linear-gradient(top, #67e827 5%, #81de52 100%);
background: -ms-linear-gradient(top, #67e827 5%, #81de52 100%);
background: linear-gradient(to bottom, #67e827 5%, #81de52 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#67e827', endColorstr='#81de52', GradientType=0);
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
display: inline-block;
border: 0px;
cursor: pointer;
color: #ffffff !important;
font-family: Arial;
font-size: 15px;
font-weight: bold;
padding: 5px 11px;
text-decoration: none;
}
/* the green button when hovered over */
.btn-signature-green:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #81de52), color-stop(1, #67e827));
background: -moz-linear-gradient(top, #81de52 5%, #67e827 100%);
background: -webkit-linear-gradient(top, #81de52 5%, #67e827 100%);
background: -o-linear-gradient(top, #81de52 5%, #67e827 100%);
background: -ms-linear-gradient(top, #81de52 5%, #67e827 100%);
background: linear-gradient(to bottom, #81de52 5%, #67e827 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#81de52', endColorstr='#67e827', GradientType=0);
background-color: #81de52;
color: black !important;
}
/* the green button when clicked */
.btn-signature-green:active {
position: relative;
top: 1px;
}
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<button class="btn-signature-green" id="updateAccountButton">disabled button</button>
The disabled style is overlapped by the parent style.
Instead of background-color, use background on :disabled style.
And the parent button has got color style with !important so it is needed to set the color with important on :disabled selector style.
And to disable hover effect when disabled, it is needed to set pointer-events: none;.
$(window).on("load", function() {
document.getElementById("updateAccountButton").disabled = "disabled";
});
/* disabled button */
.btn-signature-blue:disabled, .btn-signature-green:disabled, .btn-signature-red:disabled {
background: red;
color: blue !important;
pointer-events: none;
}
.btn-signature-green {
-moz-box-shadow: 0px 6px 11px -7px #5fd623;
-webkit-box-shadow: 0px 6px 11px -7px #5fd623;
box-shadow: 0px 6px 11px -7px #5fd623;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #67e827), color-stop(1, #81de52));
background: -moz-linear-gradient(top, #67e827 5%, #81de52 100%);
background: -webkit-linear-gradient(top, #67e827 5%, #81de52 100%);
background: -o-linear-gradient(top, #67e827 5%, #81de52 100%);
background: -ms-linear-gradient(top, #67e827 5%, #81de52 100%);
background: linear-gradient(to bottom, #67e827 5%, #81de52 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#67e827', endColorstr='#81de52', GradientType=0);
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
display: inline-block;
border: 0px;
cursor: pointer;
color: #ffffff !important;
font-family: Arial;
font-size: 15px;
font-weight: bold;
padding: 5px 11px;
text-decoration: none;
}
/* the green button when hovered over */
.btn-signature-green:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #81de52), color-stop(1, #67e827));
background: -moz-linear-gradient(top, #81de52 5%, #67e827 100%);
background: -webkit-linear-gradient(top, #81de52 5%, #67e827 100%);
background: -o-linear-gradient(top, #81de52 5%, #67e827 100%);
background: -ms-linear-gradient(top, #81de52 5%, #67e827 100%);
background: linear-gradient(to bottom, #81de52 5%, #67e827 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#81de52', endColorstr='#67e827', GradientType=0);
background-color: #81de52;
color: black !important;
}
/* the green button when clicked */
.btn-signature-green:active {
position: relative;
top: 1px;
}
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<button class="btn-signature-green" id="updateAccountButton">disabled button</button>
You are using two different properties, you are setting a background on your button but a background-color on the disabled, background takes priority so it looks like it doesn't work as you'd expect.
To fix this you just need to use the same properties between disabled and active buttons.

linear-gradient on text not browserproof

My issue is purely crossbrowser and i have tried almost everything. From importing the code from http://www.colorzilla.com/gradient-editor/ to playing with every possible combination and prefixes.
I have a H1 class wich is styled (primarely) :
.welcome h1 {
line-height: 1em;
margin: 0;
font-size: 120px;
background: -webkit-linear-gradient(#7c6510, #b9a044, #7c6510);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
padding-bottom: 25px;
text-shadow: 0px 0px 17px #b9a044;
}
<div class="welcome-container"><div class="welcome text-center"><h1>Pluche Lingerie</h1></div></div>
This works great in Chrome and Safari. But not in Mozilla and IE (v11)
So i have tried this:
.welcome h1 {
line-height: 1em;
margin: 0;
font-size: 120px;
background: -webkit-linear-gradient(#7c6510, #b9a044, #7c6510);
background: #7c6510;
/* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzdjNjUxMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2I5YTA0NCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM3YzY1MTAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #7c6510 0%, #b9a044 50%, #7c6510 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #7c6510), color-stop(50%, #b9a044), color-stop(100%, #7c6510));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #7c6510 0%, #b9a044 50%, #7c6510 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #7c6510 0%, #b9a044 50%, #7c6510 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, #7c6510 0%, #b9a044 50%, #7c6510 100%);
/* IE10+ */
background: linear-gradient(to bottom, #7c6510 0%, #b9a044 50%, #7c6510 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#7c6510', endColorstr='#7c6510', GradientType=0);
/* IE6-8 */
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
-moz-background-clip: text;
-moz-text-fill-color: transparent;
-o-background-clip: text;
-o-text-fill-color: transparent;
-ms-background-clip: text;
-ms-text-fill-color: transparent;
padding-bottom: 25px;
text-shadow: 0px 0px 17px #b9a044;
}
<div class="welcome-container"><div class="welcome text-center"><h1>Pluche Lingerie</h1></div></div>
And each combination possible (also without trying to make this work for IE). All i get is a beautifull background gradient in IE and Mozilla with white font. I have no idea what i am doing wrong, why does the:
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
and the versions for moz and ie not work?
Thanks!

CSS - Gradients In IE

I am having trouble displaying buttons with gradients in IE. My CSS seems to be fine in FireFox and Chrome, but IE seems to be giving issues.
CSS:
.btn {
cursor: pointer;
border: none;
display: inline-block;
margin: 0;
line-height: 1;
width: 100%;
padding: 0.5em 0;
text-align: center;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
-ms-border-radius: 6px;
-o-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 0 4px rgba(51, 51, 51, 0.125);
-moz-box-shadow: 0 0 4px rgba(51, 51, 51, 0.125);
box-shadow: 0 0 4px rgba(51, 51, 51, 0.125);
width: 300px;
}
.btn--primary {
border: 1px solid #3A6896;
color: white;
font-size: 1.2em;
}
.btn--primary {
background: #09427c;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #2597FE), color-stop(100%, #015CAE));
background-image: -webkit-linear-gradient(#2597FE, #015CAE);
background-image: -moz-linear-gradient(#2597FE, #015CAE);
background-image: -o-linear-gradient(#2597FE, #015CAE);
background-image: linear-gradient(#2597FE, #015CAE);
}
.btn--primary:hover, .btn--primary:focus, .btn--primary[disabled] {
background: #09427c;
background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #0b5299), color-stop(100%, #07335f));
background-image: -webkit-linear-gradient(#0b5299, #07335f);
background-image: -moz-linear-gradient(#0b5299, #07335f);
background-image: -o-linear-gradient(#0b5299, #07335f);
background-image: linear-gradient(#0b5299, #07335f);
}
Here's my fiddle: http://jsfiddle.net/oampz/Wm67h/
Any help would be appreciated.
Thanks
UPDATE:
Created a new fiddle: http://jsfiddle.net/oampz/Wm67h/6/ using one of the generators mentioned, is fine in FF, looks even worse in IE!
UPDATE
This fiddle: http://jsfiddle.net/Wm67h/7/ is better in IE however does not have rounded borders/edges and the hover property doesnt work.
Use filter to make it work for IE.
For Instance,
.yourClass{
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='xx', endColorstr='xx',GradientType=0 );
}
Replace 'xx' with your gradient values.
Hope this helps.
Think your gradient code is wrong, try this:
background-image: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0, #2599FE),
color-stop(0.8, #015DAE)
);
background-image: -o-linear-gradient(bottom, #2599FE 0%, #015DAE 80%);
background-image: -moz-linear-gradient(bottom, #2599FE 0%, #015DAE 80%);
background-image: -webkit-linear-gradient(bottom, #2599FE 0%, #015DAE 80%);
background-image: -ms-linear-gradient(bottom, #2599FE 0%, #015DAE 80%);
background-image: linear-gradient(to bottom, #2599FE 0%, #015DAE 80%);
Fiddle
if you need help with gradients, I have always found this generator to be very useful

Can't combine CSS Sprite and Background Gradient in Chrome/Safari

This used to work fine, however recently the gradient doesn't work properly in Webkit. Seems to be fine in Firefox. Can someone check if I'm setting something incorrectly. Don't pay attention to the images. Its the gradient I can't get to render. Any ideas please?
JSFIDDLE: http://jsfiddle.net/UdxUg/2/
-webkit-gradient
It's due to the old syntax, generally webkit/blink now allows using a vendor-less value.
Generally you should use a :pseudo-element --> http://jsfiddle.net/UdxUg/6/
anyways here's a code that works.
works with image
.create {
border: 1px solid #63ac5c;
background: #d9ead8 url('http://tinyurl.com/mezxsk6') no-repeat 0px -10px;
background: url('http://tinyurl.com/mezxsk6') no-repeat 0px -10px, -webkit-gradient(linear, left top, left bottom, color-stop(0%, #dbe8d9), color-stop(100%, #bcd7b9));
/* Safari 4+, Chrome 2+ */
background: url('http://tinyurl.com/mezxsk6') no-repeat 0px -10px, -moz-linear-gradient(top, #dbe8d9, #bcd7b9);
background: url('http://tinyurl.com/mezxsk6') no-repeat 0px -10px, -webkit-linear-gradient(top, #dbe8d9, #bcd7b9);
background: url('http://tinyurl.com/mezxsk6') no-repeat 0px -10px, linear-gradient(top, #dbe8d9, #bcd7b9);
height: 23px;
text-align:center;
}
use this instead though
.create {
border: 1px solid #63ac5c;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #dbe8d9), color-stop(100%, #bcd7b9)); /* Safari 4+, Chrome 2+ */
background: -webkit-linear-gradient(top, #dbe8d9, #bcd7b9);
background: -moz-linear-gradient(top, #dbe8d9, #bcd7b9);
background: linear-gradient(top, #dbe8d9, #bcd7b9);
height: 23px;
text-align:center;
position: relative
}
.create:before {
content: '';
background: #d9ead8 url('http://tinyurl.com/mezxsk6') no-repeat 0 0;
height: 23px;
width: 23px;
position: absolute;
top: 0;
left: 0;
}
Check this I always use this generator to generate gradients, it is faster and it is good.
CSS3 Ultimate Gradient Generator
BTW if you remove that images the gradient works just fine in webkit.
Check on jsFiddle
.create {
border: 1px solid #63ac5c;
background: rgb(188,215,185); /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIyNCUiIHN0b3AtY29sb3I9IiNiY2Q3YjkiIHN0b3Atb3BhY2l0eT0iMSIvPgogICAgPHN0b3Agb2Zmc2V0PSI5OSUiIHN0b3AtY29sb3I9IiNkYmU4ZDkiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(188,215,185,1) 24%, rgba(219,232,217,1) 99%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(24%,rgba(188,215,185,1)), color-stop(99%,rgba(219,232,217,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(188,215,185,1) 24%,rgba(219,232,217,1) 99%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(188,215,185,1) 24%,rgba(219,232,217,1) 99%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(188,215,185,1) 24%,rgba(219,232,217,1) 99%); /* IE10+ */
background: linear-gradient(to bottom, rgba(188,215,185,1) 24%,rgba(219,232,217,1) 99%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bcd7b9', endColorstr='#dbe8d9',GradientType=0 ); /* IE6-8 */
height: 23px;
text-align:center;
}

How to create this image button in css?

I created this png image which I use for button in a web site. The problem is that the png picture must be used several times and this increases the network traffic. I want to create the same picture in css and use it as button. Can you help to create this button in css, please?
If you are using the same image file in several places, it is only being downloaded once.
That being said, this button is easy to do in CSS:
<input type="submit" class="button" value="New Router" />
.button {
background: #eeeeee; /* Old browsers */
background: -moz-linear-gradient(top, #eeeeee 0%, #b4b4b4 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(100%,#b4b4b4)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #eeeeee 0%,#b4b4b4 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #eeeeee 0%,#b4b4b4 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #eeeeee 0%,#b4b4b4 100%); /* IE10+ */
background: linear-gradient(to bottom, #eeeeee 0%,#b4b4b4 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#b4b4b4',GradientType=0 ); /* IE6-9 */
border: solid #676767 2px;
border-radius: 3px;
color: #111;
font-family: Trebuchet, Arial, Helvetica, Sans-serif;
font-size: 12pt;
font-weight: normal;
height: 18pt;
line-height: 18pt;
text-align:center;
}

Resources