码迷,mamicode.com
首页 > Web开发 > 详细

HTML与CSS之display:none

时间:2018-08-03 14:40:12      阅读:343      评论:0      收藏:0      [点我收藏+]

标签:oct   style   poi   gif   margin   png   lang   image   tpi   

技术分享图片
 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>下拉框</title>
 6     <style>
 7         *{
 8             margin :0;
 9             padding: 0;
10         }
11         div{
12             cursor: pointer;     /*鼠标样式设置为小手*/
13             width: 300px;
14             margin: 0 auto;
15             border: 1px lightgreen solid;
16         }
17         h3{
18             background-color: lightpink;
19             text-align: center;
20             text-size: 20px;
21             color: white;
22             font-weight: bold;
23         }
24         ul{
25             text-decoration: none;   /*去除列表样式*/
26             display: none;    /*将列表隐藏*/
27         }
28         div:hover ul{
29             display: block;     /*当鼠标点击div出现列表*/
30             list-style: none;
31         }
32         div ul li{
33             text-align: center;
34             color: cornflowerblue;
35             font-size: 15px;
36             line-height: 26px;
37         }
38     </style>
39 </head>
40 <body>
41 <div>
42     <h3>标题</h3>
43     <ul>
44         <li>这是列表项1</li>
45         <li>这是列表项2</li>
46         <li>这是列表项3</li>
47         <li>这是列表项4</li>
48     </ul>
49 </div>
50 </body>
51 </html>
View Code

技术分享图片

当鼠标点击标题时出现列表项。

 

HTML与CSS之display:none

标签:oct   style   poi   gif   margin   png   lang   image   tpi   

原文地址:https://www.cnblogs.com/Lia-633/p/9413030.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!