本文介绍: HTML基础之CSS样式表(一)

1.CSS内部样式

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
    <meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
    <title&gt;Document</title&gt;
    <style>
        h1{
            color: red;
        }
        h2{
            color: yellow;
        }
        h3{
            color: blue;
        }
    </style>
</head>
<body>
    <h1>11111111111</h1>
    <h2>22222222222</h2>
    <h3>33333333333</h3>

</body>
</html>

2.外部样式表

<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>
    <!-- CSS外部引入方式1 -->
    <link rel="stylesheet" type="text/css" href="../css/index.css"/>
    <!-- CSS外部引入方式2,type属性可以省略 -->
    <style type="text/css">
        @import url("../css/index.css");
    </style>
</head>
<body>
    <h1>111111</h1>
    <h2>2222222</h2>
    <h3>333333</h3>
</body>

3.行内样式表

<!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>行内样式内联样式嵌入式样式</title>
</head>
<body>
    <div style="width: 200px; height:200px; color: red;">我是div</div>
    
</body>
</html>

4.样式表优先级

5.标签选择器

6.类选择器

7.id选择器

8.通配符选择器

*{ margin:0;padding:0; }

9.群组和后代选择器

<!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>
        /* div{
            background-color: yellow;
        }
        p{
            background-color: yellow;
        }
        h1{
            background-color: yellow;
        } */
        *{
            margin: 0;
            padding: 0;
        }

        /* 群组选择器:提出公共代码,节约代码量 */
        div,.boxp,h1{
            background-color: yellow;
        }
    </style>

</head>
<body>
    <div>111111111111111</div>
    <p class="boxp">1111111111111111</p>
    <h1>111111111111</h1>
    
</body>
</html>
<!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>

/* 后代选择器空格选择器),使用空格 */
        div p{
            background-color: yellow;
        }
    </style>

</head>
<body>
    <div>
        <p>
            111111111111
        </p>
    </div>

    <p>2222222222222</p>
    
</body>
</html>

10.伪类选择

<!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:link{
            color: yellow;
        }
/* 点击过后 */
        a:visited{
            color: red;
        }
        /* 鼠标悬停 */
        a:hover{
color: blue;
        }

        /* 点击激活,激活的那一刻 */
        a:active{
            color: green;
        }
    </style>
</head>
<body>
    <a href="http://www.baidu.com">百度</a>
</body>
</html>

11.新闻导航案例

<!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:link{
            background-color: black;
            color: white;
        }

        a:visited{
            background-color: black;
            color: white;
        }

        a:hover{
            background-color: red;
        }

        a:active{
            background-color: red;
        } */

        a{
            background-color: black;
            color: white;
        }

        a:hover{
            background-color: red;
        }

        /* a:active{
            background-color: red;
        } */

        .home{
            background-color: red;
        }
    </style>

</head>
<body>
    <a href="" class="home">首页</a>
    <a href="">国内</a>
    <a href="">国际</a>
    <a href="">军事</a>
    <a href="">财经</a>
</body>
</html>

12.选择器权重

个数 选择器 权重,CSS中用四位数表示权重,权重的表达方式如:0,0,0,0
1 类型元素选择器) 0001
2 Class选择器(类选择器) 0010
3 id选择器 0100
4 包含选择器 包含选择符的权重之和
5 内联选择器 1000
6 !import 10000
CSS选择器解析规则1: 不同选择符的样式设置冲突时候,高权重选择器符的样式会覆盖低权重选择符的样式
CSS选择器解析规则2: 相同权重的选择符,样式遵循就近原则,哪个选择符最后定义,就采用哪个选择符样式

13.文本属性

个数 属性 描述 说明
1 fontsize 字体大小 单位px浏览器默认是16px设计常用字号是12px
2 fontfamily 字体 字体中是中文字体英文字体中有空格时,需加双引号多个字体中间用逗号链接,先解析第一个字体,如果没有解析第二个字体,以此类推
3 color 颜色 color:red color:#ff0; color:rgb(255,0,0) 0-255,rgba()–最后一个数字表示透明度
4 fontweight 加粗 font-weight:bolder(更粗的)/bold(加粗)/normal(常规) font-weight:100-900;100-500不加粗,600-900加粗
5 font-style 倾斜 font-style:italic(斜体字)/oblique(倾斜文字)/normal(常规显示
6 textalign 文本水平对齐 text-align:left水平靠左text-align:right水平靠右text-align:center;水平居中text-align:justify;水平两端对齐,但是只对多行作用
7 line-height 行高 lline-height的数据=height的数据,可以实现单行文本垂直居中,行高
8 textindent 首行缩进 textindent可以取负值;text-indent属性只对第一行起作用,一般使用2em,即相对字体大小的两倍
9 letterspacing 间距 控制文字文字之间距离字符间距
10 wordspacing 间距 可以取负值
11 textdecoration 文本修饰 textdecoration:none没有(一般用在超链接中)/underline下划线/overline上划线/line-through删除线,如果要使用多个,使用空格隔开
12 font 文字简写 font是font-style font-weight font-size/line-height fomtfamily的简写。例:font:italic 800 30px/80px "宋体"顺序不能改变,必须同时指定font-size和font-family属性时才起作用
13 texttransform 大小写 capitalize–首字母大写lowercase小写,uppercase全部大写none不做设置

14.千锋简介案例

<!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>
        .title {
            height: 50px;
            width: 200px;
            font-size: 25px;
            background-color: #808080;
            color: #fff;
            text-align: center;
            line-height: 50px;
        }

        .p1 {
            width: 500px;
            font-size: 20px;
            text-indent: 2em;
        }

        span {
            color: red;
        }
    </style>
</head>

<body>
    <p class="title">千锋简介</p>
    <p class="p1"><strong>Lorem ipsum, dolor sit amet consectetur </strong>adipisicing elit.
        Fuga, amet modi pariatur dolorem
        officia, quas quasi
        aliquid molestiae qui,
        <span>deleniti mollitia magnam praesentium quaerat at animi tempore </span>
        assumenda quibusdam ex.
    </p>

    <p class="p1">Lorem,<strong> ipsum dolor sit amet consectetur adipisicing</strong> elit. Natus assumenda, dolore
        libero
        explicabo, commodi
        minima voluptate molestiae et excepturi provident animi in iure exercitationem aperiam vel nostrum repellat
        mollitia voluptas!</p>
    <p class="p1">Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusamus reiciendis adipisci dolore ex
        maxime libero
        provident debitis inventore soluta voluptatem quisquam, illum hic in accusantium! Perspiciatis fuga quis
        voluptatem corporis.</p>

</body>

</html>

在这里插入图片描述

15.列表属性

个数 属性 描述 说明
1 list-style-type 定义列表符合样式 list-style-type:disc实心圆)/circle(空心圆)/square(实心方块)/none(去掉符号)
2 list-style-image 图片设置列表符合样式 list-style-image:url();
3 list-style-position 设置列表标记放置位置 list-style-position:outside;列表的外面 默认值 list-style-position:inside列表里面
4 list-style 简写 list-style:none去除列表符号 list-style:disc url() inside(这里顺序可以随便改换)

16.背景属性

个数 属性 描述 说明
1 background-color 背景颜色 background-color:red
2 background-image 背景图片 background-image:url()
3 background-repeat 背景图片的平铺 background-repeat:no-repeat/repeat/repeat-x/repeat-y
4 background-position 背景图片定位 background-position:水平位置 垂直位置;可以给负值(可以给数值也可以使用rightleftcenter
5 background-attachment 背景图片的固定 background-attachment:scorll(滚动默认值)/fixed(固定固定浏览器窗口固定之后就相对浏览器窗口了)
可以简写成background
6 background-size 背景图片的大小 `background-size:500px 500px
<!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>
        .box1 {
            width: 200px;
            height: 200px;
            background-color: yellow;
        }

        .box2 {
            width: 900px;
            height: 1000px;
            background-color: rgba(255, 0, 0, 0.549);
            background-image: url("../img/2056332.jpg");
            background-size: contain;
            background-repeat: no-repeat;
            background-attachment: fixed;
        }

        .box3 {
            width: 500px;
            height: 270px;
            background-color: green;
            background-image: url("../img/2056309.jpg");
            /*
            默认是平铺效果
            */
            background-repeat: no-repeat;
            background-position: 70% 10%;
            /* background-position: right top; */
            background-size: contain;
            background-attachment: scroll;

        }
    </style>
</head>

<body>
    <div class="box1">大家<div class="box2"></div>
    </div>
    <div class="box3">

    </div>

</body>

</html>

17.视觉案例

<!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>
        div {
            width: 100%;
            height: 100%;
            background-color: white;
            background-position: center;
            background-size: cover;
            background-attachment: fixed;

        }

        .box1 {
            background-image: url("../img/2056309.jpg");

        }

        .box2 {
            background-image: url("../img/2056332.jpg");
        }

        .box3 {
            background-image: url("../img/2056359.jpg");
        }

        * {
            margin: 0;
            padding: 0;
        }

        html,
        body {
            height: 100%;
        }
    </style>
</head>

<body>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>

</body>

</html>

18.知乎案例

<!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>
        .box {
            width: 50%;
            height: 100%;
            background-color: yellow;
            margin: 0 auto;

        }

        * {
            margin: 0;
            padding: 0;
        }

        html,
        body {
            height: 100%;
        }

        body {
            background-image: url("../img/2056309.jpg");
            background-position: center;
            background-size: cover;
            background-attachment: fixed;
        }
    </style>
</head>

<body>
    <div class="box">

    </div>

</body>

</html>

19.背景的复合属性

<!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>
        /* 
复合写法:
1.使用空格隔开
2.顺序可以换
3.可以只取一个值,放在后面的能覆盖前面的值
4.background-size必须独立写
*/
        div {
            width: 300px;
            height: 300px;
            /* background-color: yellow;
            background-image: url("../img/2056309.jpg");
            background-position: center;
            background-repeat: no-repeat;
            background-size: contain;
            background-attachment: fixed; */
            background: yellow url("../img/2056309.jpg") center no-repeat fixed;
            background-size: contain;
            margin: 0 auto;

        }

        * {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div></div>
</body>

</html>

20.浮动属性

个数 属性 描述 说明
1 float float:left 元素左边浮动
2 float float:right 元素右边浮动
3 float float:none 元素浮动
浮动的作用1: 定义网页中其他文本如何环绕元素显示
浮动的作用2: 就是让竖着的东西横着来
4 clear Clear:none; 允许有浮动对象
5 clear Clear:right 不允许右边有浮动对象
6 clear Clear:right 不允许左边有浮对象
7 clear Clear:both 不允许有浮动对象
清除浮动只是改变元素排列方式,该元素还是漂浮着,不占据文档位置
<!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>
        div {
            width: 50%;
            height: 200px;
        }

        .red {
            background-color: red;
        }

        .yellow {
            background-color: yellow;
            width: 40%;
            float: left;
        }

        .blue {
            background-color: blue;

        }
    </style>
</head>

<body>
    <div class="red"></div>
    <div class="yellow"></div>
    <div class="blue"></div>
</body>

</html>
<!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>
        .box1,
        .box2 {
            width: 100px;
            height: 100px;
            float: left;

        }

        .box {
            width: 100px;
            height: 200px;
            background-color: blue;
        }

        .box1 {
            background-color: red;

        }

        .box2 {
            background-color: yellow;
        }

        /* 1.写死高度 */

        /* .container {
            height: 100px;
        } */

        /* 2.清浮动 */

        /* .box {
            clear: left;
        } */

        /* 3.当前浮动元素后面补一个盒子,不设置宽高,clear:both */

        /* 4.overflow:hidden */
        .container {
            overflow: hidden;
            /* bfc,让浮动元素计算高度 */
        }
    </style>

</head>

<body>
    <div class="container">
        <div class="box1"></div>
        <div class="box2"></div>
        <!-- <div style="clear: left;"></div> -->
    </div>

    <div class="box"></div>
</body>

</html>

21.浮动案例

<!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>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            float: left
        }

        div img {
            width: 187px;
            height: 125px;
        }

        div p {
            font-size: 12px;
            text-align: center;
            background-color: #f6f7f8;
            width: 187px;
        }
    </style>
</head>

<body>
    <div>
        <img
            src="http://contentcms-bj.cdn.bcebos.com/cmspic/a0f393d56f8964e95dcd077d3ed5e332.jpeg?x-bce-process=image/crop,x_0,y_57,w_640,h_430" />
        <p>吴磊时尚大片曝光 少年感十足</p>
    </div>
    <div>
        <img
            src="http://contentcms-bj.cdn.bcebos.com/cmspic/ad344613749749a3cd6305c34f29e98f.jpeg?x-bce-process=image/crop,x_0,y_91,w_640,h_430" />
        <p>吴磊时尚大片曝光 少年感十足</p>
    </div>
    <div>
        <img
            src="http://contentcms-bj.cdn.bcebos.com/cmspic/9fed4f6b5d6d22dde9af8195ff0598db.jpeg?x-bce-process=image/crop,x_0,y_305,w_640,h_430" />
        <p>吴磊时尚大片曝光 少年感十足</p>
    </div>
    <div>
        <img
            src="http://contentcms-bj.cdn.bcebos.com/cmspic/9379a58fe77d92527306ff58888f3ecd.jpeg?x-bce-process=image/crop,x_0,y_39,w_640,h_430" />
        <p>吴磊时尚大片曝光 少年感十足</p>
    </div>
    <div>
        <img
            src="http://contentcms-bj.cdn.bcebos.com/cmspic/c122866cea6c6df373f02b0e215a2cd6.jpeg?x-bce-process=image/crop,x_43,y_26,w_470,h_315" />
        <p>吴磊时尚大片曝光 少年感十足</p>
    </div>
</body>

</html>

22.盒子模型

在这里插入图片描述

<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>
        div {
            width: 500px;
            height: 300px;
            background-color: yellow;
            text-align: justify;
            /* 内边距 */
            /* 1个值表示四个方向都一样,2个值表示上下和左右 */
            /* 3个值:上,左右,下
            4个值:上,右,下,左 */
            padding: 30px;
        }
    </style>
</head>

<body>
    <div>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptas tempora eligendi culpa. Accusantium aspernatur
        minus asperiores impedit quibusdam cumque magni culpa vitae amet. Excepturi, id doloremque. Alias repudiandae
        voluptas aperiam?
    </div>
</body>

在这里插入图片描述

内边特性

边框

border:1px solid gray

外边特性

margin:1px 2px 3px 4px

1.兄弟关系

<!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>
        /* 群组选择器 */
        .box1,
        .box2,
        .box3,
        .box4 {
            width: 100px;
            height: 100px;
        }

        .box1 {
            background-color: red;
            margin-bottom: 20px;


        }

        .box2 {
            background-color: yellow;
            margin-top: 10px;
        }

        .box3 {
            background-color: blue;
            float: left;
            margin-right: 20px;
        }

        .box4 {
            background-color: green;
            float: left;
            margin-left: 10px;
        }
    </style>
</head>

<body>

    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
    <div class="box4"></div>
</body>

</html>

2.父子关系

<!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>
        .box1,
        .box2 {
            padding: 0;
        }

        .box1 {
            width: 500px;
            height: 500px;
            background-color: red;
            margin-top: 10px;
            /* padding-top: 10px; */
            /* border: 1px solid transparent; */
            /* float: left; */
            overflow: hidden;
        }

        .box2 {
            width: 200px;
            height: 100px;
            background-color: yellow;
            margin-top: 30px;
            margin-left: 0;
            /* float: left; */
        }


        /* 1.子margin-top转化为父的padding-top */
        /* 2.给父盒子设置边框 */
        /* 3.给父或者子盒子添加浮动 */
        /* 4.overflow:hidden BFC块,不会影响外部*/
    </style>
</head>

<body>
    <div class="box1">
        <div class="box2"></div>
    </div>
</body>

</html>

23.PS基本操作

ps===图片处理软件(美工用来作图前端用来测量,吸取颜色,切图

拿到设计稿之后使用ps打开

24.盒子案例

在这里插入图片描述

<!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>
        * {
            margin: 0;
            padding: 0;
        }

        img {
            display: block;
        }

        #box {
            width: 241px;
            height: 335px;
            background-color: white;
            margin: 0 auto;
            padding: 11px 11px 18px;
        }

        .title {
            width: 235px;
            height: 19px;
            background-color: rgb(252, 250, 250);
            padding-left: 4px;
            border-left: 2px solid blue;
            color: blue;
            font-size: 14px;
            line-height: 19px;
            font-weight: bold;
            margin-bottom: 12px;
        }

        /* .bigpic {
            width: 241px;
            height: 170px;
        } */

        .bigpic p {
            width: 241px;
            height: 26px;
            background-color: #f6f7f8;
            font-size: 12px;
            text-align: center;
            /* 垂直方向居中 */
            line-height: 26px;
            margin-bottom: 16px;
        }

        .smallpic p {
            font-size: 12px;
            width: 112px;
            background-color: #f6f7f8;
            line-height: 18px;
            text-align: center;
        }

        .smallpic img {
            width: 112px;
            height: 70px;
        }

        .left {
            float: left;
        }

        .right {
            float: right;
        }
    </style>
</head>

<body>
    <div id="box">
        <div class="title">女人图片</div>
        <div class="bigpic">
            <img src="../img/2056309.jpg" style="width: 241px;height:170px" alt="" />
            <!-- <img src="../img/2056309.jpg" /> -->
            <p>这是一张无关紧要的图片</p>
        </div>
        <div class="smallpic">
            <div class="left">
                <img src="../img/2056332.jpg" alt="" />
                <p>啊哈哈哈,我滴任务完成</p>
            </div>

            <div class="right">
                <img src="../img/2056359.jpg" alt="" />
                <p>给你机会你不中用啊</p>
            </div>
        </div>
    </div>
</body>

</html>

25.溢出属性

1.溢出属性(容器的)

说明:

overflow:visible/hidden(隐藏)/scroll/auto(自动)/inherit;

<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>
        .box1 {
            width: 200px;
            height: 200px;
            background-color: yellow;
            /* overflow: visible;显示溢出 */
            /* overflow: hidden;溢出隐藏,文本裁切 */
            /* overflow: scroll;有没有溢出,都会有滚动条 */
            /* overflow: auto;只有溢出时才会有滚动条 */
            /* overflow: inherit;继承父元素的效果 */
            overflow: auto;
        }

        .box {
            width: 500px;
            height: 100px;
            overflow-y: auto;
            /* 要配合使用 */
            overflow-x: hidden;
        }
    </style>
</head>

<body>
    <div class="box1">
        Lorem ipsum dolor, sit amet consectetur adipisicing elit. Modi officia impedit commodi, quibusdam repellendus
        repudiandae ex ullam neque iusto id debitis dolorum? Consequatur iure reprehenderit fugiat quos reiciendis
        tempora pariatur.

    </div>
    <div class="box"><img src="../img/2056309.jpg"></div>
</body>

2.空余空间

说明:

说明:

单行文本溢出显示省略号需要同时设置以下声明

1.容器宽度width:200px

2.强制文本在一行内显示:white-space:nowrap

3.溢出内容为隐藏:overflow:hidden

4.溢出文本显示省略号text-overflow:ellipsis

26.溢出属性案例

在这里插入图片描述

<!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>
        * {
            margin: 0;
            padding: 0;
        }

        #box {
            width: 890px;
            height: 290px;
            background-color: white;
            margin: 0 auto;
            overflow: auto;
        }

        .info {
            width: 162px;
            height: 112px;
            border: 1px solid #808080;
            float: left;
            margin-right: 48px;
            margin-bottom: 20px;
        }

        .info div {
            width: 162px;
            height: 84px;
            background-color: #cccccc;
            background-image: url("../img/2056359.jpg");
            background-size: cover;
            font-size: 13px;
        }

        .price {
            height: 63px;
            line-height: 63px;
            padding-left: 21px;
            color: #b5b5b5;
        }

        .info .date {
            color: #b5b5b5;
            padding-left: 21px;
        }

        .category {
            background-color: white;
            height: 28px;
            line-height: 28px;
            color: #000;
            text-align: center;
            font-size: 12px;
        }

        .info:hover div {
            background-color: #219cea;
            background-image: url("../img/2056309.jpg");


        }

        .info:hover .price {
            color: white;
        }

        .info:hover .date {
            color: white
        }

        .info:hover .category {
            color: #219cea;
            background-image: url("../img/2056332.jpg");
            background-repeat: no-repeat;
            background-size: contain;
            background-position: right bottom;
        }
    </style>
</head>

<body>
    <div id="box">
        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>

        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>
        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>
        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>
        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>
        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>
        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>
        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>
        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>
        <div class="info">
            <div>
                <p class="price">¥100.00圆</p>
                <p class="date">有效期至:2022-8-4</p>
            </div>
            <p class="category">[店铺类][商城类]</p>
        </div>


    </div>
</body>

</html>

原文地址:https://blog.csdn.net/m0_50315078/article/details/126167030

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_42378.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注