zoukankan      html  css  js  c++  java
  • 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.  浮动

         从父元素的边缘开始挨着排列 
        - 父元素宽度不够的时候,浮动元素会掉下来,掉到浮动所设置的位置,比如左浮动,元素会掉到做百年
        - 元素设置浮动后会脱离文档流,没有设置浮动的元素会占据浮动元素的位置,文字不会被遮挡
        - 浮动元素不会超过没有设置浮动的元素
      * **浮动的应用场景**
        - 将纵向排列的元素横向排列,给每一个需要横向的排列的元素都添加浮动   
  • 相关阅读:
    关于异步IO与同步IO的写操作区别
    慢慢开始记录一些技术心得吧
    写了placement new就要写placement delete
    关于针对class自定义new操作符失败的函数处理
    operator->和operator->*
    关于继承中的拷贝构造函数
    关于g++编译模板类的问题
    关于互斥锁,条件变量的内核源码解析
    关于sigwait
    观察者设计模式
  • 原文地址:https://www.cnblogs.com/qdbj2020/p/13457682.html
Copyright © 2011-2022 走看看