Internet Explorer Filters are a pure CSS implementation that, when used in conjunction with the HTML5 Boilerplate <html>
conditional comments, requires no hacks and validates (almost) perfectly!
Note that gradients display a color between an element’s background its and content (meaning an element’s background color will shine through the gradient).
Also note that this CSS will not validate because filter
is invalid. If validation is important to you, this could be served via an IE-only stylesheet.
Lastly, note that Firefox 3.5- and, as of this writing, Opera, do not support background gradients, so if you are concerned with either of these browser versions, you might want to also include a background gradient image. By referencing the no-cssgradients
class, and placing it before the .ie
class, you prevent the image from being downloaded by browsers that do support background gradients), even though it doesn’t really need it, IE would get the download…I never said this would all be perfect…
Okay, really the last note, here is another alternative for Opera, again, if you’re really interested.
#example1 { background: #d1c26c; /* Old browsers */ background-image: -moz-linear-gradient(top, #d1c26c 0%, #e5e2b9 22%, #d1cd96 66%, #b5a75c 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d1c26c), color-stop(22%,#e5e2b9), color-stop(66%,#d1cd96), color-stop(100%,#b5a75c)); /* Chrome,Safari4+ */ background-image: -webkit-linear-gradient(top, #d1c26c 0%,#e5e2b9 22%,#d1cd96 66%,#b5a75c 100%); /* Chrome10+,Safari5.1+ */ background-image: -o-linear-gradient(top, #d1c26c 0%,#e5e2b9 22%,#d1cd96 66%,#b5a75c 100%); /* Opera11.10+ */ background-image: -ms-linear-gradient(top, #d1c26c 0%,#e5e2b9 22%,#d1cd96 66%,#b5a75c 100%); /* IE10+ */ background-image: linear-gradient(top, #d1c26c 0%,#e5e2b9 22%,#d1cd96 66%,#b5a75c 100%); /* W3C */ } html.lte9 #example1 { filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#D1C26C', endColorstr='#B5A75C',GradientType=0 ); /* IE6-9 */ zoom: 1; /* 'hasLayout' required for HTC method */ }
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Leave a Reply