Help us understand the problem. What is going on with this article?

HTML+CSS ドロップダウンメニュー

ドロップダウンで表示するメニューの要素に”display: none”を設定しておき、ホバー時に、displayを切り替えるだけ。

HTML

index.html
<!DOCTYPE html>
<html>

<head>
  <title>transarent nav bar</title>
  <link rel="stylesheet" type="text/css" href="css/styles.css">
</head>

<body>

  <ul>
    <li>
      <a href="#">Home</a></li>
    <li><a href="#">About</a>
      <ul>
        <li><a href="">profile</a></li>
      </ul>
    </li>
    <li><a href="#">Category</a>
      <ul>
        <li><a href="">category1</a></li>
        <li><a href="">category2</a></li>
        <li><a href="">category3</a></li>
        <li><a href="">category4</a></li>
      </ul>
    </li>
    <li><a href="#">Contents</a>
      <ul>
        <li><a href="">content1</a></li>
        <li><a href="">content2</a></li>
      </ul>
    </li>
    <li><a href="#">New</a></li>
  </ul>

</body>

</html>

CSS

styles.css
body {
 background-size: none;
 margin-left: 10%;
}

ul {
 margin: 0px;
 padding: 0px;
 list-style: none;
 font-family: arial;
}

ul li {
 float: left;
 width: 200px;
 height: 40px;
 background-color: black;
 opacity: .8;
 line-height: 40px;
 text-align: center;
 font-size: 20px;
}

ul li a {
 text-decoration: none;
 color: white;
 display: block;
}

ul li a:hover {
 background-color: green;
}

/*非表示にしておく*/
ul li ul li{
 display: none; 
}

/*ドロップダウンの要素を表示*/
ul li:hover ul li {
 display: block;
}


スクリーンショット 2019-12-03 11.57.52.png

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした