2023.05.04学习

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            margin: 0;
        }
        .sub-header{
            height: 100px;
            background-color: #b8b8b8;
        }
        .container{
            width: 1128px;
            margin:0 auto;
        }
        .sub-header .ht{
            height:100px;
        }
        .sub-header .logo{
            width:234px;
            float: left;
        }
        .sub-header .logo a{
            margin-top: 22px;
            display: inline-block
        }
        .sub-header .logo a img{
            height: 56px;
            width: 56px
        }
        .sub-header .menu-list{
            float:left;
            line-height: 100px;
        }
        .sub-header .menu-list a{
            padding: 0 10px;
            display: inline-block;
            color: #333;
            font-size: 16px;
            text-decoration: none;
        }

        .sub-header .menu-list a:hover{
            color: #ff6700;
        }
        .sub-header .search{
            float:right;
        }
    </style>
</head>
<body>
<div class="sub-header">
    <div class="container">
        <div class="ht logo">
            <!--a标签是行内标签,默认设置高度、边距无效。->块级 & 行内+块级  display: inline-block;-->
            <a href="https://www.mi.com/shop">
                <img src="images/logo-mi2.png" alt="">
            </a>
        </div>
        <div class="ht menu-list">
            <a href="http://www.mi.com">Xiaomi手机</a>
            <a href="http://www.mi.com">Redmi红米</a>
            <a href="http://www.mi.com">电视</a>
            <a href="http://www.mi.com">笔记本</a>
            <a href="http://www.mi.com">平板</a>
        </div>
        <div class="ht search">3</div>
        <div class="clear:both;"></div>
    </div>
</div>
</body>
</html>

1.3案例:顶部菜单+二级菜单

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body {
            margin: 0;
        }
        .container {
            width: 1226px;
            margin: 0 auto;
        }
        .header {
            background: #333;
        }
        .header .menu {
            float: left;
            color: white;
        }
        .header .account {
            float: right;
            color: white;
        }
        .header a {
            color: #b0b0b0;
            line-height: 40px;
            display: inline-block;
            font-size: 12px;
            margin-right: 10px;
            text-decoration: none;
        }
        .header a:hover{
            color: white;
        }
        .sub-header {
            height: 100px;
            background-color: white;
        }
        .sub-header .ht{
            height:100px;
        }
        .sub-header .logo{
            width:234px;
            float: left;
        }
        .sub-header .logo a{
            margin-top: 22px;
            display: inline-block
        }
        .sub-header .logo a img{
            height: 56px;
            width: 56px
        }
        .sub-header .menu-list{
            float:left;
            line-height: 100px;
        }
        .sub-header .menu-list a{
            padding: 0 10px;
            display: inline-block;
            color: #333;
            font-size: 16px;
            text-decoration: none;
        }
        .sub-header .menu-list a:hover{
            color: #ff6700;
        }
        .sub-header .search{
            float:right;
        }
    </style>
</head>
<body>
    <div class="header">
        <div class="container">
            <div class="menu">
                <a href="http://www.mi.com">小米商城</a>
                <a href="http://www.mi.com">MIUI</a>
                <a href="http://www.mi.com">云服务</a>
                <a href="http://www.mi.com">有品</a>
                <a href="http://www.mi.com">开放平台</a>
            </div>
            <div class="account">
                <a href="http://www.mi.com">登录</a>
                <a href="http://www.mi.com">注册</a>
                <a href="http://www.mi.com">消息通知</a>
            </div>
            <div style="clear:both"></div>
        </div>
    </div>
    <div class="sub-header">
    <div class="container">
        <div class="ht logo">
            <!--a标签是行内标签,默认设置高度、边距无效。->块级 & 行内+块级  display: inline-block;-->
            <a href="https://www.mi.com/shop">
                <img src="images/logo-mi2.png" alt="">
            </a>
        </div>
        <div class="ht menu-list">
            <a href="http://www.mi.com">Xiaomi手机</a>
            <a href="http://www.mi.com">Redmi红米</a>
            <a href="http://www.mi.com">电视</a>
            <a href="http://www.mi.com">笔记本</a>
            <a href="http://www.mi.com">平板</a>
        </div>
        <div class="ht search">3</div>
        <div class="clear:both;"></div>
    </div>
</div>
</body>
</html>

小结:

a标签是行内标签,行内标签的高度、内外边距,默认无效

垂直方向居中

        本文+line-height

        图片+边距

a标签默认有下划线

鼠标放上去之后字体有变化用hover

.c1:hover{

        ...

}

a:hover{


}

案例:整合

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body {
            margin: 0;
        }

        img {
            width: 100%;
            height: 100%;
        }

        .left{
            float: left;
        }

        .container {
            width: 1226px;
            margin: 0 auto;
        }

        .header {
            background: #333;
        }

        .header .menu {
            float: left;
            color: white;
        }

        .header .account {
            float: right;
            color: white;
        }

        .header a {
            color: #b0b0b0;
            line-height: 40px;
            display: inline-block;
            font-size: 12px;
            margin-right: 10px;
            text-decoration: none;
        }

        .header a:hover {
            color: white;
        }

        .sub-header {
            height: 100px;
            background-color: white;
        }

        .sub-header .ht {
            height: 100px;
        }

        .sub-header .logo {
            width: 234px;
            float: left;
        }

        .sub-header .logo a {
            margin-top: 22px;
            display: inline-block
        }

        .sub-header .logo a img {
            height: 56px;
            width: 56px
        }

        .sub-header .menu-list {
            float: left;
            line-height: 100px;
        }

        .sub-header .menu-list a {
            padding: 0 10px;
            display: inline-block;
            color: #333;
            font-size: 16px;
            text-decoration: none;
        }

        .sub-header .menu-list a:hover {
            color: #ff6700;
        }

        .sub-header .search {
            float: right;
        }

        .slider .sd-img {
            width: 1226px;
            height: 460px;
        }

        .slider .sd-img img {
            width: 100%;
            height: 100%;
        }
        .news{
            margin-top: 14px;
        }
        .news .channel{
            width: 228px;
            height: 164px;
            background-color: #5f5750;
            padding: 3px;
        }
        
        .news .channel .item{
            width: 72px;
            height: 86px;
            float: left;
            text-align: center;
        }

        .news .channel .item a{
            font-size: 12px;
            display: inline-block;
            padding-top: 18px;
            color: #fff;
            text-decoration: none;
            opacity: 0.7;
        }
        .news .channel .item a:hover{
            opacity: 1;
        }
        .news .channel .item img{
            height: 24px;
            width: 24px;
            display: block;
            margin: 0 auto 4px;


        }
        .news .list-item{
            width: 316px;
            height: 170px;
            display: block;
            margin: 0 auto;
        }

    </style>
</head>
<body>
    <div class="header">
        <div class="container">
            <div class="menu">
                <a href="http://www.mi.com">小米商城</a>
                <a href="http://www.mi.com">MIUI</a>
                <a href="http://www.mi.com">云服务</a>
                <a href="http://www.mi.com">有品</a>
                <a href="http://www.mi.com">开放平台</a>
            </div>
            <div class="account">
                <a href="http://www.mi.com">登录</a>
                <a href="http://www.mi.com">注册</a>
                <a href="http://www.mi.com">消息通知</a>
            </div>
            <div style="clear:both"></div>
        </div>
    </div>
    <div class="sub-header">
        <div class="container">
            <div class="ht logo">
                <!--a标签是行内标签,默认设置高度、边距无效。->块级 & 行内+块级  display: inline-block;-->
                <a href="https://www.mi.com/shop">
                    <img src="images/logo-mi2.png" alt="">
                </a>
            </div>
            <div class="ht menu-list">
                <a href="http://www.mi.com">Xiaomi手机</a>
                <a href="http://www.mi.com">Redmi红米</a>
                <a href="http://www.mi.com">电视</a>
                <a href="http://www.mi.com">笔记本</a>
                <a href="http://www.mi.com">平板</a>
            </div>
            <div class="ht search"></div>
            <div class="clear:both;"></div>
        </div>
    </div>
    <div class="slider">
        <div class="container">
            <div class="sd-img">
                <img src="images/b1.jpg" alt="">
            </div>
        </div>
</div>
    <div class="news">
        <div class="container">
            <div class="channel left">
                <div class="item">
                    <a href="http://www.mi.com">
                        <img src="images/x1.jpg" alt=""/>
                        <span>保障服务</span>
                    </a>
                </div>
                <div class="item">
                    <a href="http://www.mi.com">
                        <img src="images/x2.jpg" alt=""/>
                        <span>企业团购</span>
                    </a>
                </div>
                <div class="item">
                    <a href="http://www.mi.com">
                        <img src="images/x3.jpg" alt=""/>
                        <span>F码通道</span>
                    </a>
                </div>
                <div class="item">
                    <a href="http://www.mi.com">
                        <img src="images/x4.jpg" alt=""/>
                        <span>米粉卡</span>
                    </a>
                </div>
                <div class="item">
                    <a href="http://www.mi.com">
                        <img src="images/x5.jpg" alt=""/>
                        <span>以旧换新</span>
                    </a>
                </div>
                <div class="item">
                    <a href="http://www.mi.com">
                        <img src="images/x6.jpg" alt=""/>
                        <span>话费充值</span>
                    </a>
                </div>
                <div class="clear:both"></div>
            </div>
            <div class="list-item left" style="margin-left: 14.6px">
                <img src="images/n1.jpg" alt=""/>
            </div>
            <div class="list-item left" style="margin-left: 14.6px">
                <img src="images/n2.jpg" alt=""/>
            </div>
            <div class="list-item left" style="margin-left: 14.6px">
                <img src="images/n3.jpg" alt=""/>
            </div>
            <div class="clear:both"></div>
        </div>
    </div>
</body>
</html>

小结:设置透明度

opacity:0.7/1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值