The secondary drop-down menu a:hover style cannot be called_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:18:13
Original
1155 people have browsed it

This post was last edited by kxteb0cc on 2013-01-07 18:46:49

I wrote two a:hover, but the second-level drop-down menu always uses the hover of the first-level navigation. This Why? Is my code written wrong? Asking for expert advice!

<style type="text/css">/* 一级导航 */* {margin: 0; padding: 0;}ul {list-style: none;}a {text-decoration: none;}body {margin-top: 5px;}#nav {background: #39F; widht: 100%; height: 30px; line-height: 30px;}#nav ul {float: left; position: relative; left: 50%;}#nav ul li {float: left; position: relative; right: 50%;}#nav a {display: block; width: 100px; margin: 0 5px; text-align: center;}#nav a:hover {background: #FFF; color: #F00;}/* 二级导航 */.nav_list {position:absolute; left: 0; top: 30px; width: 98px; border: 1px solid #000; background: #F60; line-height: 30px; overflow: hidden;}.nav_list a {display: block; color: #FFF; width: 100px; text-align: center; color: #F00;}.nav_list a:hover {background: #0F0; color: #00F;}</style></head><body>  <div id="nav">    <ul>      <li><a href="#">电影</a>        <div class="nav_list">          <ul>            <li><a href="#">动作片</a></li>            <li><a href="#">喜剧片</a></li>            <li><a href="#">科幻片</a></li>          </ul>        </div>      </li>      <li><a href="#">电视剧</a></li>      <li><a href="#">综艺</a></li>    </ul>  </div>
Copy after login


Reply to the discussion (solution)

#nav .nav_list {position:absolute; left: 0; top: 30px; width: 98px; border: 1px solid #000; background: #F60; line-height: 30px; overflow: hidden;}#nav .nav_list a {display: block; color: #FFF; width: 100px; text-align: center; color: #F00;}#nav .nav_list a:hover {background: #0F0; color: #00F;}
Copy after login

Modify to this because the selector determines priority based on importance degree.
The id selector has a higher priority than the class selector

XML/HTML code?123#nav .nav_list {position:absolute; left: 0; top: 30px; width: 98px; border: 1px solid #000; background: #F60; line-height: 30px; overflow: hidden;}#nav .nav_list a {displ...
Thank you, it was solved

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template