返回下拉菜单的案例...登陆

下拉菜单的案例

阿涛2019-06-28 16:23:26290

html代码:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <link rel="stylesheet" href="static/css/style3.css">

    <title>下拉菜单案例</title>

</head>

<body>

<div class="header">

 

    <div class="nav">

        <a class="qnzx" href="#">千牛卖家中心

        <ul>

            <li>免费开店</li>

            <li>已卖出的宝贝</li>

            <li>出售中的宝贝</li>

            <li>体检中心</li>

            <li>问商友</li>

        </ul>

        </a>

    </div>

</div>

 

</body>

</html>

css代码:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

*{

    margin0;

    padding0;

}

 

.header {

    height35px;

    width100%;

    background-color#F5F5F5;

    border-bottom1px solid #EEEEEE;

}

 

.nav {

    height36px;

    width200px;

    margin0 auto;

    /*background-color: palevioletred;*/

}

 

a {

    text-aligncenter;

    line-height36px;

    text-decorationnone;

    color#6C6C6C;

    display: inline-block;

    width200px;

    height36px;

    /*margin: auto;*/

}

 

a:hover{

    color#FF4400;

    background-colorwhite;

}

 

.nav:hover {

    background-colorwhite;

    border-left1px solid #cccccc;

    border-right1px solid #cccccc;

    padding-left1px;

 

}

 

.nav:hover ul{

    displayblock;

}

 

ul li:hover{

    background-color#F5F5F5;

}

 

ul li {

    list-stylenone;

    text-alignleft;

    padding8px;

 

}

 

ul {

 

    width201px;

    border1px solid #cccccc;

    border-topnone;

    displaynone;

    positionrelative;

    right2px;

}

效果图:

QQ截图20190628155653.png

总结:

1、首先清空浏览器自带的边距。

2、css盒模型熟悉掌握后,对元素的微调能很好把握。

3、案例中使用相对定位对其了下拉菜单上下的边框线。

4、下拉菜单的实现原理和实现过程从案例中都有很好的体现。

最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送