So here's my issue, I'm trying to get this effect
So I'd use this CSS
background-image: -webkit-gradient(
linear,
left top,
left bottom,
color-stop(0, #5FC7F4),
color-stop(1, #069ADA)
);
background-image: -o-linear-gradient(bottom, #5FC7F4 0%, #069ADA 100%);
background-image: -moz-linear-gradient(bottom, #5FC7F4 0%, #069ADA 100%);
background-image: -webkit-linear-gradient(bottom, #5FC7F4 0%, #069ADA 100%);
background-image: -ms-linear-gradient(bottom, #5FC7F4 0%, #069ADA 100%);
background-image: linear-gradient(to bottom, #5FC7F4 0%, #069ADA 100%);
Now what happens is when I use that, I get
As you can see there are "layers", and its not exactly a "smooth" gradient. Here's a demo http://jsfiddle.net/U4FU3/
And ideas?
Nothing's wrong with your gradient - you just need to set the height like so:
html, body {
height: 100%;
}
#gradient {
height: 200px;
background: -webkit-linear-gradient(#5FC7F4, #069ADA ); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(#5FC7F4, #069ADA ); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(#5FC7F4, #069ADA ); /* For Firefox 3.6 to 15 */
background: linear-gradient(#5FC7F4, #069ADA); /* Standard syntax (must be last) */
}
This seems to work fine
Check out this example:
http://www.w3schools.com/css/tryit.asp?filename=trycss3_gradient-linear
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 am using an gradient with opacity as an brightness effect for JUST my background. Now it works in Chrome and Firefox but doesn't seem to work in IE10, but I did put the -ms- version there.
Here is my JSFiddle: >>>JSFiddle<<<
Here is the code:
<div id="lol">
</div>
-
#lol {
background-image:url('http://www.gettyimages.com/CMS/Pages/PhotoDiscFrontdoor/StaticContent/fd_image_test.jpg');
width:700px;
height:465px;
}
#lol:hover {
background: -moz-linear-gradient(top, rgba(255,255,255,.1) 0%, rgba(255,255,255,.1) 100%), url('http://www.gettyimages.com/CMS/Pages/PhotoDiscFrontdoor/StaticContent/fd_image_test.jpg');
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,.1)), color-stop(100%,rgba(255,255,255,.1))), url('http://www.gettyimages.com/CMS/Pages/PhotoDiscFrontdoor/StaticContent/fd_image_test.jpg');
background: -webkit-linear-gradient(top, rgba(255,255,255,.1) 0%,rgba(255,255,255,.1) 100%), url('http://www.gettyimages.com/CMS/Pages/PhotoDiscFrontdoor/StaticContent/fd_image_test.jpg');
background: -o-linear-gradient(top, rgba(255,255,255,.1) 0%,rgba(255,255,255,.1) 100%), url('http://www.gettyimages.com/CMS/Pages/PhotoDiscFrontdoor/StaticContent/fd_image_test.jpg');
background: -ms-linear-gradient(top, rgba(255,255,255,.1) 0%,rgba(255,255,255,.1) 100%), url('http://www.gettyimages.com/CMS/Pages/PhotoDiscFrontdoor/StaticContent/fd_image_test.jpg');
background: linear-gradient(to bottom, rgba(255,255,255,.1) 0%,rgba(255,255,255,.1) 100%), url('http://www.gettyimages.com/CMS/Pages/PhotoDiscFrontdoor/StaticContent/fd_image_test.jpg');
}
Does anyone know what is wrong with this code? Why doesn't it work in Internet Explorer 10?
Thanks in advance.
html
<div></div>
css
div{
width: 500px;
height: 500px;
background: linear-gradient(to top, #00f, #fff);
}
Does anyone know how to make ie work for gradient effect?
I have also applied filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00f', endColorstr='#fff');
but it works differently in ie. You can see this in your test page, copy and paste then see the different between them. IE has deep color.
This is what you should have for cross-browser solution:
background: rgb(255,255,255);
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(0,0,255,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(0,0,255,1)));
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(0,0,255,1) 100%);
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(0,0,255,1) 100%);
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(0,0,255,1) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(0,0,255,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#0000ff',GradientType=0 );
Here is a working example. Also I recommend using some gradient generator for this. Makes your life a lot easier. For example try colorzilla
try this one
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#0000ff', GradientType='0');
I got this code from css graident generator, which is transparent at the bottom of the gradient
background: -moz-linear-gradient(top, rgba(248,246,247,1) 0%, rgba(248,246,247,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(248,246,247,1)), color-stop(100%,rgba(248,246,247,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(248,246,247,1) 0%,rgba(248,246,247,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(248,246,247,1) 0%,rgba(248,246,247,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(248,246,247,1) 0%,rgba(248,246,247,0) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(248,246,247,1) 0%,rgba(248,246,247,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f8f6f7', endColorstr='#00f8f6f7',GradientType=0 ); /* IE6-9 */
Now I want to add a background on top of the gradient background
background: url('../images/letter_head.png') left top repeat-x, #f8f6f6;
How do I combine them both?
Just prepend the url of the image to each of your rules.
background: url(someurl), -moz-linear-gradient(top, rgba(248,246,247,1) 0%, rgba(248,246,247,0) 100%); /* FF3.6+ */
Alternatively, if you don't feel like adding url(etc) to each of your rules, you could just specify a single background-image rule:
background: -moz-linear-gradient(top, rgba(248,246,247,1) 0%, rgba(248,246,247,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(248,246,247,1)), color-stop(100%,rgba(248,246,247,0))); /* Chrome,Safari4+ */
...
background-image:url("someurl");
CSS
.bg{
width:800px; height:750px;
background: #38BAC9 url(http://www.google.com/logos/2012/india12-hp.jpg) 10% no-repeat;
background:url(http://www.google.com/logos/2012/india12-hp.jpg) center no-repeat, -webkit-gradient(linear, 0% 0%, 0% 100%, from(#57BEED), to(#38BAC9));
background:url(http://www.google.com/logos/2012/india12-hp.jpg) center no-repeat, -moz-linear-gradient(top, #57BEED 0%, #38BAC9 100%);
}
DEMO
Check this link for more information
http://userinterfacehome.blogspot.in/2012/09/css-multiple-background.html
How can i make this background with css3? Image
I want to repeat it and want not use a image.
thanks for help
You can do this using CSS3 gradients:
background: -moz-linear-gradient(top, #ffffff 0%, #ffffff 49%, #eaa82c 50%, #eaa82c 80%, #bc2020 81%, #bc2020 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(49%,#ffffff), color-stop(50%,#eaa82c), color-stop(80%,#eaa82c), color-stop(81%,#bc2020), color-stop(100%,#bc2020)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#ffffff 49%,#eaa82c 50%,#eaa82c 80%,#bc2020 81%,#bc2020 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#ffffff 49%,#eaa82c 50%,#eaa82c 80%,#bc2020 81%,#bc2020 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#ffffff 49%,#eaa82c 50%,#eaa82c 80%,#bc2020 81%,#bc2020 100%); /* IE10+ */
background: linear-gradient(top, #ffffff 0%,#ffffff 49%,#eaa82c 50%,#eaa82c 80%,#bc2020 81%,#bc2020 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#bc2020',GradientType=0 ); /* IE6-9 */
}
http://jsfiddle.net/gDJtD/
I suggest you have a look at http://lea.verou.me/css3patterns/ for this
Having said that, images are always going to be faster. Beware of not using css gradients just for the sake of using css gradients.