简体   繁体   中英

CSS not working on the left sidebar but on the upper bar

The code given below is working on the upper bar, but it will not work on the left bar.

 #one { display: block; background-color: red; } #two { opacity: 0; background-color: green; position: relative; top: -34px; } #two:hover { opacity: 1; } 
 <html> <head> <link rel="stylesheet" type="text/css" href="hov.css"> </head> <body> <div id="one"> <p>mango</p> </div> <div id="two"> <p>apple</p> </div> </body> </html> 

The above code works if the mango is on the top and it will not work when the mango is on the left side.

Where is the sidebar ? there is only two container set to block.

 #one { display: block; background-color: red; } #two { opacity: 0; background-color: green; position: relative; top: -34px; } #two:hover { opacity: 1; } 
 <html> <head> <link rel="stylesheet" type="text/css" href="hov.css"> </head> <body> <div id="one"> <p>mango</p> </div> <div id="two"> <p>apple</p> </div> </body> </html> 

Are you looking for this ?

 #one { width:100px; display: block; background-color: red; } #two { opacity: 0; background-color: green; position: relative; top: -34px; margin-left:100px; } #two:hover { opacity: 1; } 
  <div id="one"> <p>mango</p> </div> <div id="two"> <p>apple</p> </div> 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM