• 05-背景图与浮动的练习


    2020-08-08

    1. 通过无序列表属性与伪类选择器完成。
     li:hover{
                color: brown;
        }

    例图

      2.背景图

    background :背景图的颜色 背景图的路径 背景图的重复方式 背景图位置

      3.

    背景图的固定 background-attachment:
    源码
    ···
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            *{
                margin: 0 ;
                padding: 0;
            }
            .box1{
                height: 800px;
                text-align: center;
                background: purple url(img/jn.jpg) no-repeat center;
                background-size: 100%;
                background-attachment: fixed;
                color: white;
            }
            .box2{
                height: 800px;
                text-align: center;
                background: palegreen url(img/hzy.jpg) no-repeat center;
                background-size: 100%;
                background-attachment: fixed;
                color: white;
            }
            .box3{
                height: 800px;
                text-align: center;
                background: forestgreen url(img/mdx.jpg) no-repeat center;
                background-size: 100% 100%;
                background-attachment: fixed;
                color: white;
            }
        </style>
    </head>
    <body>
        <div class="box1">第一张图:基努里维斯</div>
        <div class="box2">第二张图:河正宇</div>
        <div class="box3">第三张图:马东锡</div>
    </body>
    </html>
    ···

      fixed;固定

      scoll;滚动 

      3.  浮动

         从父元素的边缘开始挨着排列 
        - 父元素宽度不够的时候,浮动元素会掉下来,掉到浮动所设置的位置,比如左浮动,元素会掉到做百年
        - 元素设置浮动后会脱离文档流,没有设置浮动的元素会占据浮动元素的位置,文字不会被遮挡
        - 浮动元素不会超过没有设置浮动的元素
      * **浮动的应用场景**
        - 将纵向排列的元素横向排列,给每一个需要横向的排列的元素都添加浮动   
  • 相关阅读:
    【BZOJ1452】【JSOI2009】count
    【BZOJ1030】【JSOI2007】文本生成器
    【BZOJ2427】【HAOI2010】软件安装
    从【BZOJ4173】谈做题技巧
    小A的旅行(绿豆蛙的归宿)【期望DP】
    甜点 【多重背包】
    洛谷 [P1154] 奶牛分厩
    POJ [P2631] Roads in the North
    洛谷 [P3258] 松鼠的新家
    洛谷 [P3398] 仓鼠找sugar
  • 原文地址:https://www.cnblogs.com/qdbj2020/p/13457682.html
Copyright © 2020-2023  润新知