zoukankan      html  css  js  c++  java
  • CSS 背景图片 添加 重复和定位。

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <title>CSS 背景色. 背景图片. 背景重复. 背景图片固定和定位 </title>
    <style type="text/css">
    body{
    height:3000px;
    background-image:url(C:/Users/Administrator/Desktop/xxx.png);
    background-repeat:no-repeat;
    background-position:bottom;/*向下的*/
    background-attachment:fixed;
    /*给网页3000px高度 来观察背景图像固定属性 background-attachment:fixed*/
    }
    h1{
    text-align:center;
    }
    p{
    background-color:pink;

    }
    div{
    /* 给背景添加图片 一定要注意 图片的取值路径 */
    background-image:url(C:/Users/Administrator/Desktop/xxx.png);
    background:no-repeat; /* bupingpu */
    background-repeat:repeat-x;/*1.background-repeat:repeat-x 我是水平平铺 */
    background-repeat:repeat-y;/*2.background-repeat:repeat-y 我是垂直平铺*/
    background-attachment:fixed;
    /* background-position:5px 6px; */
    border:1px solid red;
    height:100px;
    }
    </style>
    </head>
    <body>
    <h1>1.背景色</h1>
    <p>1.属性:background-color <br>
    2.注意:背景颜的会填充到元素的边框 内边距 内容区域。
    </p>

    <h1>2.背景图片</h1>
    <p>属性:background-image<br>
    取值:URL(图像路径)
    </p>
    <div id="" class="">
    小星星
    </div>

    <h1>3.背景重复</h1>
    <p>1.默认情况 背景图会在水平 和 垂直两个方向(就是平铺)<br>
    属性:background-repeat
    取值repeat:默认值,水平垂直平铺。
    repeat-x: 水平平铺;
    repeat-y: 垂直平铺;
    no-repeart:不平铺;
    </p>
    <h1>4.背景图像固定</h1>
    <p>属性:background-attachment<br>
    取值
    fixed,背景图像固定 <br>background-attachment:fixed;

    </p>

    <h1>5.背景定位</h1>
    <p>改变背景图像在元素中的位置<br>
    属性:background-position<br>
    取值:x y <br>
    x表示水平方向移动 +向右 -向左<br>
    y表示垂直方向 +向上 -向下<br>
    x% y% :
    0% 0% : 显示在元素的左上方
    100% 100% : 显示在元素的右下方
    50% 50% : 居中
    left :靠左
    right:靠右
    center :将元素显示在水平或垂直方向的中间
    top:靠上
    bottom:靠下
    background-position:left top;
    background-position:top left;
    background-position:center;

    </p>


    </body>
    </html>2019-02-21

  • 相关阅读:
    深入理解TCP、UDP协议及两者的区别
    Java多线程之Executor框架
    Java中的线程池及其实现类ThreadPoolExecutor
    深入理解java虚拟机之Java对象头
    深入理解Java虚拟机之创建对象,即创建一个类的过程
    使用RedisTemplate操作Redis数据库
    深入理解Java虚拟机之运行时数据区域
    多线程之join方法
    线程之间的通信方式:wait/notify
    多线程之可见性:volatile
  • 原文地址:https://www.cnblogs.com/ZXF6/p/10415027.html
Copyright © 2011-2022 走看看