Related
I have this background:
.background:hover {
background: #F4F4F4 url(../images/arrow_down_over.gif) no-repeat right;
}
that I would like to change into a gradient like this one :
.background:hover{
background: -moz-linear-gradient(top, #f4f4f4 0%, #eeeeee 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f4f4f4), color-stop(100%,#eeeeee)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f4f4f4 0%,#eeeeee 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f4f4f4 0%,#eeeeee 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f4f4f4 0%,#eeeeee 100%); /* IE10+ */
background: linear-gradient(to bottom, #f4f4f4 0%,#eeeeee 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f4f4f4', endColorstr='#eeeeee',GradientType=0 );
} /* IE6-9 */
But I would like to keep the arrow image. I can't find a way to do it. I did try something like this:
background: -moz-linear-gradient(top, #f4f4f4 0%, #eeeeee 100%) url(../images/arrow_down_over.gif) no-repeat right; /* FF3.6+ */
or add this after the gradient properties but without any success.
background: url(../images/arrow_down_over.gif) no-repeat right;
I can't add another class so I have to deal with this CSS. Any idea how to do it?
You may try:
background: url(../images/arrow_down_over.gif), linear-gradient(...);
Multiple backgrounds must be comma-separated rather than space-separated, and they weirdly stack from top to bottom.
Also note that this is not necessarily supported by all browsers.
See http://css-tricks.com/stacking-order-of-multiple-backgrounds/ and https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Using_multiple_backgrounds for details
I have to realize this pattern for a background web site. Who can help me to realize the pattern? I don't know how it has to be developed.
I have realized the gradient with this css3 code:
background: rgb(152,152,152); /* Old browsers */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzk4OTg5OCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMSIvPgogICAgPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZmZmZmZmIiBzdG9wLW9wYWNpdHk9IjEiLz4KICA8L2xpbmVhckdyYWRpZW50PgogIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9InVybCgjZ3JhZC11Y2dnLWdlbmVyYXRlZCkiIC8+Cjwvc3ZnPg==);
background: -moz-linear-gradient(left, rgba(152,152,152,1) 0%, rgba(255,255,255,1) 100%, rgba(255,255,255,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(152,152,152,1)), color-stop(100%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(152,152,152,1) 0%,rgba(255,255,255,1) 100%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(152,152,152,1) 0%,rgba(255,255,255,1) 100%,rgba(255,255,255,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(152,152,152,1) 0%,rgba(255,255,255,1) 100%,rgba(255,255,255,1) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(152,152,152,1) 0%,rgba(255,255,255,1) 100%,rgba(255,255,255,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#989898', endColorstr='#ffffff',GradientType=1 ); /* IE6-8 */
As commented, it is used as a fallback for some old browsers e.g. I.E.6
background: rgb(152,152,152); /* Old browsers */
Include an inline background image (using base64 encoding instead of a url)
background: url(data:image/svg+xml;base64,PD94bWw...);
For the -xx-linear-gradient lines, we call it vendor-specific properties.
background: -moz-linear-gradient(left, rgba(152,152,152,1) 0%, rgba(255,255,255,1) 100%, rgba(255,255,255,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(152,152,152,1)), color-stop(100%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(152,152,152,1) 0%,rgba(255,255,255,1) 100%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(152,152,152,1) 0%,rgba(255,255,255,1) 100%,rgba(255,255,255,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(152,152,152,1) 0%,rgba(255,255,255,1) 100%,rgba(255,255,255,1) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(152,152,152,1) 0%,rgba(255,255,255,1) 100%,rgba(255,255,255,1) 100%); /* W3C */
They are not necessarily to be standard W3C rules. The purpose of the existence of vendor-specific props is to allow browser vendors to add their own CSS props for providing more features than what the standard suggested to developers.
The last line is used by I.E. that supports "filter" property.
So in short, the lines below the first line are just doing the same job but they are just designed for use by different browsers. It ensures that the element with the rules applied to look the same in all major browsers.
My button is Chrome is appearing like this.
This is what I want.
In Firefox, however, it appears like this.
.mainButton_grey {
border: 1px solid BFBFBF;
background: -webkit-linear-gradient(top,#DBDBDB,#D1D1D1);
padding-top:7px;
text-align:center;
cursor:pointer;
width:200px;
height:22px;
border-radius:3 3;
background-color:#0972BD;
font-size:11px;
font-weight:bold;
font-family:Arial;
color:#404040;
}
Jsfiddle here.
Just a word of advice for gradients - if you want as much browser compatibility as possible, add the following (just change the values).
background: -moz-linear-gradient(black, white); /* FF 3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #000000), color-stop(100%, #ffffff)); /* Safari 4+, Chrome 2+ */
background: -webkit-linear-gradient(black, white); /* Safari 5.1+, Chrome 10+ */
background: -o-linear-gradient(black, white); /* Opera 11.10 */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#ffffff'); /* IE6 & IE7 */
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#000000', endColorstr='#ffffff')"; /* IE8+ */
background: linear-gradient(black, white); /* the standard fallback for old browsers */
Syntax explanation here: http://www.impressivewebs.com/css3-linear-gradient-syntax/
And there's an awesome gradient generator here: http://www.colorzilla.com/gradient-editor/
The reason is because you haven't defined the linear gradient with:
-moz-linear-gradient(top, #DBDBDB, #D1D1D1);
The syntax may be a little different; but each browser has a different way to interpret the gradient.
Here is an example of a gradient with each browser:
background: rgb(245,246,246); /* Old browsers */
background: -moz-linear-gradient(top, rgba(245,246,246,1) 0%, rgba(219,220,226,1) 21%, rgba(184,186,198,1) 49%, rgba(221,223,227,1) 80%, rgba(245,246,246,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(245,246,246,1)), color-stop(21%,rgba(219,220,226,1)), color-stop(49%,rgba(184,186,198,1)), color-stop(80%,rgba(221,223,227,1)), color-stop(100%,rgba(245,246,246,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f6f6', endColorstr='#f5f6f6',GradientType=0 ); /* IE6-9 */
Hopefully that helps.
Three things:
Get your gradient CSS from this site: http://www.colorzilla.com/gradient-editor/
Update your border-radius to specify the units: border-radius: 3px 3px;
Add # to your border-color declaration: border: 1px solid #BFBFBF;
I added a gradient background for my .html page. Seems to work in most browsers but I would like to know if it is standard and complies to all rules.
.css
html {
/* fallback */
background-color: #65a5d1;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#65a5d1));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #fff, #65a5d1);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #fff, #65a5d1);
/* IE 10 */
background: -ms-linear-gradient(top, #fff, #65a5d1);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #fff, #65a5d1);
height: 900px;
}
If you want to generate gradients that are fully compatible you can check the Ultimate CSS Gradient Generator:
Here's the output it generates:
/* Old browsers */
background: #1e5799;
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMTAwJSIgeDI9IjEwMCUiIHkyPSIwJSI+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjMWU1Nzk5IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iNTAlIiBzdG9wLWNvbG9yPSIjMjk4OWQ4IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iNTElIiBzdG9wLWNvbG9yPSIjMjA3Y2NhIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzdkYjllOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
/* FF3.6+ */
background: -moz-linear-gradient(45deg, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%);
/* Chrome, Safari4+ */
background: -webkit-gradient(linear, left bottom, right top, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8));
/* Chrome10+,Safari5.1+ */
background: -webkit-linear-gradient(45deg, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
/* Opera 11.10+ */
background: -o-linear-gradient(45deg, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
/* IE10+ */
background: -ms-linear-gradient(45deg, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
/* W3C */
background: linear-gradient(45deg, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
/* IE6-8 fallback on horizontal gradient */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=1 );
As you see it generates bit more properties to cover even more cases.
If you want support for IE 9 you'll have to follow this... yeah I know it sucks, but...
Support for full multi-stop gradients with IE9 (using SVG):
Add a "gradient" class to all your elements that have a gradient, and add the following override to your HTML to complete the IE9 support:
<!--[if gte IE 9]>
<style type="text/css">
.gradient {
filter: none;
}
</style>
<![endif]-->
I have an HTML table and am trying to add a gradient using a style attribute on the <td>. This works in IE, but not Firefox, Opera, or Chrome.
<td height="100%" width="10%" valign="top"
style="filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#6487DB', endColorStr='#003366', gradientType='0');" >
</td>
How can I get this to work in Firefox, etc.?
This:
filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#6487DB', endColorStr='#003366', gradientType='0');
is IE specific code. It shouldn't work in other browsers. See css3please for ways of doing this in other browsers (that support css3).
EDIT: copied from the link I posted previously and modified to the correct colors
background-color: #6487DB;
background-image: -webkit-gradient(linear, left top, left bottom, from(#6487DB), to(#003366)); /* Saf4+, Chrome */
background-image: -webkit-linear-gradient(top, #6487DB, #003366); /* Chrome 10+, Saf5.1+ */
background-image: -moz-linear-gradient(top, #6487DB, #003366); /* FF3.6 */
background-image: -ms-linear-gradient(top, #6487DB, #003366); /* IE10 */
background-image: -o-linear-gradient(top, #6487DB, #003366); /* Opera 11.10+ */
background-image: linear-gradient(top, #6487DB, #003366);
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#6487DB', EndColorStr='#003366'); /* IE6–IE9 */
The 'filter:progid:DXImageTransform.Microsoft.gradient' statement is for Internet Explorer only! Add this code to your stylesheet instead:
<style>
.mygradientstyle{
background:#6487DB; /* Old browsers */
background:-moz-linear-gradient(top,#6487DB 0%, #003366 100%); /* FF3.6+ */
background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#6487DB),color-stop(100%,#003366)); /* Chrome,Safari4+ */
background:-webkit-linear-gradient(top,#6487DB 0%,#003366 100%); /* Chrome10+,Safari5.1+ */
background:-o-linear-gradient(top,#6487DB 0%,#003366 100%); /* Opera11.10+ */
background:-ms-linear-gradient(top,#6487DB 0%,#003366 100%); /* IE10+ */
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#6487DB ', endColorstr='#003366',GradientType=0 ); /* IE6-9 */
background:linear-gradient(top,#6487DB 0%,#003366 100%); /* W3C */
}
</style>
... Then call your with the class 'mygradientstyle' in your sourcecode:
<td height="100%" width="10%" valign="top" class="mygradientstyle">
... This should work across all browsers.
If you want a left-to-right gradient use this code:
<style>
.mygradientstyle{
background:#6487DB; /* Old browsers */
background:-moz-linear-gradient(left,#6487DB 0%,#003366 100%); /* FF3.6+ */
background:-webkit-gradient(linear,left top,right top,color-stop(0%,#6487DB),color-stop(100%,#003366)); /* Chrome,Safari4+ */
background:-webkit-linear-gradient(left,#6487DB 0%,#003366 100%); /* Chrome10+,Safari5.1+ */
background:-o-linear-gradient(left,#6487DB 0%,#003366 100%); /* Opera11.10+ */
background:-ms-linear-gradient(left,#6487DB 0%,#003366 100%); /* IE10+ */
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#6487DB', endColorstr='#003366',GradientType=1); /* IE6-9 */
background:linear-gradient(left,#6487DB 0%,#003366 100%); /* W3C */
}
</style>
Again, the snippet background:-o-linear-gradient(left,#6487DB 0%,#003366 100%); /* Opera11.10+ */ should work with Opera version 10 or higher. Opera 9 or lower is beyond my knowledge, but think that gradients are not supported. Any insights on that anyone?