css 复习01

这个写起来简单多

a 是行内元素, 宽度由内容撑开,为了可以设置高度,所以转成了行内块,

为了让宽度变大,由于字数不一样,所以不可以直接给宽度,直接给padding 撑开就行了

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        
        .nav {
            height: 41px;
            background-color: #FCFCFC;
            /*上边框*/
            border-top: 3px solid #FF8500;
            /*下边框*/
            border-bottom: 1px solid #EDEEF0;
        }
        
        a {
            display: inline-block;
            line-height: 41px;
            text-decoration: none;
            padding: 0 10px;
            font-size: 12px;
            color: #4C4C4C;
        }
        
        a:hover {
            background: #eee;
        }
        
        .box {
            width: 500px;
            height: 300px;
            border: 1px solid #CCC;
        }
        
        .box p {
            padding-left: 20px;
            background: pink;
        }
    </style>
</head>

<body>
    <div class="nav">
        <a href="#">设为首页</a>
        <a href="#">手机新浪网</a>
        <a href="#">移动客户端</a>
        <a href="#">博客</a>
        <a href="#">微博</a>
        <a href="#">关注我</a>
    </div>

    <div class="box">
        <p>hello world</p>
    </div>

</body>

</html>

猜你喜欢

转载自blog.csdn.net/qq_15009739/article/details/113878670
今日推荐