I am trying to change the background-color
of a menu, while mouse-hover
. But it is not working.
I have used the following CSS code:
#access a:hover{
background: -moz-linear-gradient(center top , #F99733, #E47300) repeat scroll 0 0 transparent;
}
Please take a look at the page CLICK HERE
#access a:hover{
background: -moz-linear-gradient(center top , #F99733, #E47300) repeat scroll 0 0 transparent;
background: -webkit-linear-gradient(center top , #F99733, #E47300) repeat scroll 0 0 transparent;
background: -o-linear-gradient(center top , #F99733, #E47300) repeat scroll 0 0 transparent;
background: -ms-linear-gradient(center top , #F99733, #E47300) repeat scroll 0 0 transparent;
}
Try using this ,
background: linear-gradient(....
background: -moz-linear-gradient(.... /// FF3.6+
background: -webkit-linear-gradient(.... /// Chrome10+,Safari5.1+
background: -o-linear-gradient(.... /// Opera 11.10+
background: -ms-linear-gradient(.... /// IE10+
you can generate linear-gradient HERE !
Personally I like using a grey inset
box-shadow
to style my element and then I can simply swap the background colours on hover.
<div>
Example
</div>
div
{
border: 1px solid black;
padding: 10px;
font-size: 20px;
background-color: #0ff;
box-shadow: inset 0px -50px 75px -50px #000;
-moz-box-shadow: inset 0px -50px 75px -50px #000;
-webkit-box-shadow: inset 0px -50px 75px -50px #000;
}
div:hover
{
background-color: #bff;
}
Different browsers use different gradient rules, try using the code below:
div:hover {
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#F99733), to(#E47300)); /* safari & chrome */
background: -moz-linear-gradient(#F99733, #E47300); /* Firefox */
-ms-filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFF99733,endColorstr=#FFE47300); /* IE8 */
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFF99733,endColorstr=#FFE47300); /* IE 7 */
zoom: 1;
background: linear-gradient(#F99733, #E47300);
}
It doesn't work because its having issues with your :focus
pseudo selector which is applied to your <a>
.
First you need to understand that you are only supporting gecko based browsers (Mozilla Firefox) by adding the vendor prefix of -moz to your CSS.
There's a website that helps you make gradients so you can copy and paste them and they have an image as a fallback so it looks good in older browsers too.
So it will end up looking like this:
#access li a:hover,
#access li a:focus {
background: #f99733;
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPHJhZGlhbEdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY3g9IjUwJSIgY3k9IjUwJSIgcj0iNzUlIj4KICAgIDxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNmOTk3MzMiIHN0b3Atb3BhY2l0eT0iMSIvPgogICAgPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjZTQ3MzAwIiBzdG9wLW9wYWNpdHk9IjEiLz4KICA8L3JhZGlhbEdyYWRpZW50PgogIDxyZWN0IHg9Ii01MCIgeT0iLTUwIiB3aWR0aD0iMTAxIiBoZWlnaHQ9IjEwMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-radial-gradient(center, ellipse cover, #f99733 0%, #e47300 100%);
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#f99733), color-stop(100%,#e47300));
background: -webkit-radial-gradient(center, ellipse cover, #f99733 0%,#e47300 100%);
background: -o-radial-gradient(center, ellipse cover, #f99733 0%,#e47300 100%);
background: -ms-radial-gradient(center, ellipse cover, #f99733 0%,#e47300 100%);
background: radial-gradient(ellipse at center, #f99733 0%,#e47300 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f99733', endColorstr='#e47300',GradientType=1 );
}
I find that this works for me in most cases and its based on what I understand your specific needs are.
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.