html+css,part 2

目录

CSS的元素显示模式

1.什么是元素显示模式? 

2.块元素

3.行内元素

4.行内块元素

5.元素显示模式总结

 显示模式的转换

 手机官网侧栏简易版

背景

背景颜色

背景图片

背景平铺

​ 背景图片位置

背景图像固定(背景附着)

背景色半透明

背景总结

五彩导航


CSS的元素显示模式

1.什么是元素显示模式? 

2.块元素

3.行内元素

4.行内块元素

5.元素显示模式总结

 显示模式的转换

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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        a {
            width: 250px;
            height: 30px;
            background-color: rgb(51, 223, 102);
            /* 把行内元素 a 转换为 块级元素 */
            display: block;
        }

        div {
            width: 250px;
            height: 50px;
            background-color: rgb(192, 41, 41);
            /* 把块级元素 div 转换为 行内元素 */
            display: inline;
        }

        span {
            width: 250px;
            height: 50px;
            background-color: rgb(252, 255, 50);
            /* 把行内元素 span 转换为 行内块元素 */
            display: inline-block;
        }
    </style>
</head>

<body>
    <a href="#">qwq'''</a>
    <a href="#">qwq'''</a>
    <div>QAQ</div>
    <div>QAQ</div>
    <span>T-T</span>
    <span>T-T</span>
</body>

</html>

 手机官网侧栏简易版

 height: 42px;          盒子高度

line-height: 42px;    行高

行高=盒子高度大小,实现字体垂直居中

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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        a {
            display: block;
            width: 234px;
            height: 42px;
            text-decoration: none;
            color: rgb(255, 255, 255);
            background-color: rgb(156, 155, 163);
            text-indent: 2em;
            line-height: 42px;
        }

        a:hover {
            background-color: rgb(255, 103, 0);
        }
    </style>
</head>

<body>
    <a href="#">手机</a>
    <a href="#">电视</a>
    <a href="#">笔记本 平板</a>
    <a href="#">家电</a>
    <a href="#">出行 穿戴</a>
    <a href="#">智能 路由器</a>
    <a href="#">电源 配件</a>
    <a href="#">健康 儿童</a>
    <a href="#">耳机 音箱</a>
    <a href="#">生活 箱包</a>
</body>

</html>

背景

背景颜色

background-color:transparent        一般默认为透明

背景图片

背景平铺

 背景图片位置

背景图像固定(背景附着)

 

背景色半透明

背景总结

五彩导航

鼠标放在链接上变色

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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .nav a {
            display: inline-block;
            width: 115px;
            height: 70px;
            background-color: rgb(255, 159, 159);
            text-align: center;
            line-height: 58px;
            color: rgb(255, 255, 255);
            text-decoration: none;
        }

        .nav .c1 {
            background: url(images/c1.png) no-repeat;

        }

        .nav .c2 {
            background: url(images/c2.png) no-repeat;
        }

        .nav .c3 {
            background: url(images/c3.png) no-repeat;
        }

        .nav .c4 {
            background: url(images/c4.png) no-repeat;
        }

        .nav .c5 {
            background: url(images/c5.png) no-repeat;
        }

        .nav .c3:hover {
            background: url(images/c5.png);
        }

        .nav .c5:hover {
            background: url(images/c1.png);
        }

        .nav .c4:hover {
            background: url(images/c2.png);
        }

        .nav .c1:hover {
            background: url(images/c4.png);
        }

        .nav .c2:hover {
            background: url(images/c3.png);
        }
    </style>
</head>

<body>
    <div class="nav">
        <a href="#" class="c1">五彩导航</a>
        <a href="#" class="c2">五彩导航</a>
        <a href="#" class="c3">五彩导航</a>
        <a href="#" class="c4">五彩导航</a>
        <a href="#" class="c5">五彩导航</a>
    </div>
</body>

</html>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Titijiang233

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值