html - how to style image button at navigation bar like when hover, link, the image will change the pattern -


i want made when hover, active , visited, image change image, method?

now put image under background, cause when put image, word come down, want made word overlap image, can't...

if can please explain why need style this... learn use html want understand more it, thanks

<div class="navbar" style="margin-left:80px;padding-top:40px;"><!--navbar-->   <div id="navbar" >     <div id="navhome" style="width:100px;height:60px; padding-top:30px; padding-left:10px"> <a href="index.html">home</a> </div>   </div>   <div id="navbar">     <div id="navhistory" style="width:130px;height:60px; padding-top:30px; padding-left:10px;"> <a href="about.html">about us</a> </div>   </div>   <div id="navbar">     <div id="navevent" style="width:130px;height:60px; padding-top:30px; padding-left:10px"> <a href="event_1.html">event</a> </div>   </div>   <div id="navbar">     <div id="navcontact" style="width:130px;height:60px; padding-top:30px;"> <a href="contact.html">contact us</a> </div>   </div> </div> <!--navbar--> 

css:

 .navbar {     font-family: kaiti;     font-size: 22px;     color: #6c2e13;     text-align: center;     float: left; }  #navbar {     float: left;     margin-right: 5px;     margin-left: 5px; }  #navhistory {     background-image: url(../img/nav2.png);     background-repeat: no-repeat; }  #navevent {     background-image: url(../img/nav3.png);     background-repeat: no-repeat; }  #navcontact {     background-image: url(../img/nav4.png);     background-repeat: no-repeat; }  #navhome {     background-image: url(../img/nav1.png);     background-repeat: no-repeat; } 

first thing if want apply active, visited styles need apply background images anchor tag. can update background image using css. @ present applying background div. means want modify parent element when hover, active or visited actions happened. using css, child element can't modify parent element.

so check fiddle have modified code , applied same when hover, visited , active actions happened.

some sample code:

 #navhistory a{ background-image: url(http://www.w3.org/tr/2011/wd-css3-images-20110217/linear3.png); background-repeat: no-repeat; padding:0px 50px; display:inline-block; height:60px; line-height:60px; white-space:nowrap; }  #navevent a{ background-image: url(http://www.w3.org/tr/2011/wd-css3-images-20110217/radial1.png); background-repeat: no-repeat; padding:0px 50px; display:inline-block; height:60px; line-height:60px; white-space:nowrap; }  #navcontact a{ background-image: url(http://www.w3.org/tr/2011/wd-css3-images-20110217/linear1.png); background-repeat: no-repeat; padding:0px 50px; display:inline-block; height:60px; line-height:60px; white-space:nowrap; }  #navhome a{ background-image: url(http://www.w3.org/tr/2011/wd-css3-images-20110217/radial3.png); background-repeat: no-repeat; padding:0px 50px; display:inline-block; height:60px; line-height:60px; white-space:nowrap; } 

fiddle demo


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -