The code is here: http://jsfiddle.net/xEULj/
#rt-header {
width: 600px;
z-index: 2;
position: relative;
background: -webkit-linear-gradient(left, red, red 40%, green 40%, green);
background: -moz-linear-gradient(left, red, red 40%, green 40%, green);
background: -o-linear-gradient(left, red, red 40%, green 40%, green);
background: -ms-linear-gradient(left, red, red 40%, green 40%, green);
background: linear-gradient(left, red, red 40%, green 40%, green);
}
Has there been a way to make this happen in IE yet? Some work-around that I have yet to find? I've actually just found out that this doesn't work in IE10, I thought it would, coming from here: http://ie.microsoft.com/testdrive/Graphics/CSSGradientBackgroundMaker/Default.html , but I guess not.
Any ideas, or do I just need to use an image?
There is IE10 support below with gradient going from green to red.
#rt-header
{
background: #ff3232; /* Old browsers */
background: -moz-linear-gradient(left, #ff3232 1%, #ff2828 49%, #3fff30 49%, #3fff00 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(1%,#ff3232), color-stop(49%,#ff2828), color-stop(49%,#3fff30), color-stop(100%,#3fff00)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #ff3232 1%,#ff2828 49%,#3fff30 49%,#3fff00 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #ff3232 1%,#ff2828 49%,#3fff30 49%,#3fff00 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #ff3232 1%,#ff2828 49%,#3fff30 49%,#3fff00 100%); /* IE10+ */
background: linear-gradient(to right, #ff3232 1%,#ff2828 49%,#3fff30 49%,#3fff00 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff3232', endColorstr='#3fff00',GradientType=1 ); /* IE6-9 */
}
I believe you might need to use the to keyword.
try background: linear-gradient(to right, red, red 40%, green 40%, green);
You can use pseudo-elements to fill the given part of the element with the solid color:
#rt-header {
width: 600px;
z-index: 2;
position: relative;
background: green;
}
#rt-header:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 40%;
height: 100%;
background: red;
z-index: -1;
}
Should work in IE8 (tested with netrenderer.com).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.