• CSS3背景


    CSS3背景
    1.背景图像区域
    background-clip 属性 指定背景绘制区域
    语法:background-clip:boder-box|padding-box|content-box
    boder-box: 从边框盒的地方绘制图像,边框盒外的被裁剪
    padding-box:从内边距盒开始绘制背景图像,内边距外的被裁剪
    contrnt-box:从内容部分开始绘制背景图像,内容外的被裁剪
    IE9+ FireFox Chrome Safari Opera
    2.背景图像定位
    background-origin属性 指定background-position属性应该是相对位置
    设置元素背景图片的原始起始位置
    background-position定义的是背景图像的位置,有两个值,水平和垂直偏移量,都是以左上角为坐标原点
    具体左上角是什么位置就是由background-origin指定
    语法:background-origin:boder-box|padding-box|content-box
    boder-box: 从边框盒的左上角
    padding-box:从内边距盒左上角
    contrnt-box:从内容部分左上角
    IE9+ FireFox4+ Chrome Safari5+ Opera
    3.CSS3背景图片的大小
    background-size 指定背景图片的大小
    语法: background-size:length|percentage|cover|contin
    /*将背景图片等比缩放至某一边紧贴容器边缘为止*/
    background-size:contain ;
    /*将背景图片等比缩放以填满整个容器*/
    background-size: cover;
    background-size: 800px 500px;
    background-size: 800px;
    background-size: 50% 50%;
    background-size: 50%;
    background-size: 100% 100%;
    /*背景图像宽度是div宽度的100%,高度根据背景图片宽度和高度的原始比例缩放*/
    background-size: 100% ;
    兼容:IE9+ FireFox4+ Chrome Safari5+ Opera
    多重背景图像
    为元素使用多个背景图
    语法 background-image:url(img1.jpg),url(img2.png);
    元素引用多个背景图片时,前面的图片一次覆盖后面图
    背景属性整合
    背景缩放属性可以在一个声明中设置所有的背景属性
    语法:background:color position size repeat origin clip attachment image
    color position size repeat(是否重复) origin(起始位置) clip(区域) attachment(图片状态 是随页面滚屏还是固定不动)

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>背景图像定位</title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
                border:none;
            }
            div{
                 800px;
                height: 400px;
                padding: 50px;
                /*transparent半透明*/
                border: 50px solid transparent;
                /*background:color position size repeat origin clip attachment image*/
                background:red center 50% no-repeat content-box content-box fixed url("java.png")  ;
                /*background-origin: border-box;*/
                /*background-origin:padding-box;*/
                /*!*权重最后一个会超越前两个*!*/
                /*background-origin:content-box;*/
                background: green url("java.png") no-repeat center center ;
                background-size:50% ;
                background-origin: content-box;
                background-clip: content-box;
                background-attachment: fixed;
            }
            /*通过绝对位置虚拟div边框*/
            span.div_border{
                position: absolute;
                top: 0;
                left: 0;
                 800px;
                height: 400px;
                padding: 50px;
                border: 50px solid rgba(255,0,0,.25);
            }
            /*虚拟div填充*/
            span.div_padding{
                position: absolute;
                top: 50px;
                left: 50px;
                 800px;
                height: 400px;
                border: 50px solid rgba(63, 255, 52, 0.25);
            }
    
        </style>
    </head>
    <body>
    <div></div>
    <span class="div_border"></span>
    <span class="div_padding"></span>
    </body>
    </html>
    

      

  • 相关阅读:
    ixgbe dma 控制器
    per cpu
    HDU 4597 Play Game
    HDU 5115 Dire Wolf
    hdu 5900 QSC and Master
    CodeForces933A A Twisty Movement
    CodeForces 245H Queries for Number of Palindromes
    CodeForces596D Wilbur and Trees
    CodeForces509F Progress Monitoring
    CodeForces149D Coloring Brackets
  • 原文地址:https://www.cnblogs.com/alasijia/p/9223462.html
Copyright © 2020-2023  润新知