itanswer 发表于 2020-12-25 14:41:56

CSS3 背景

CSS3 中包含几个新的背景属性,提供更大背景元素控制。在本章您将了解以下背景属性:
[*]background-image
[*]background-size
[*]background-origin
[*]background-clip
CSS3 background-image属性
CSS3中可以通过background-image属性添加背景图片。不同的背景图像和图像用逗号隔开,所有的图片中显示在最顶端的为第一张。<div style="background-image: url(img/img_flwr.gif), url(img/paper.gif);
            background-position: right bottom, left top;
            background-repeat: no-repeat, repeat;">
     <br>
     <br>
     <br>
     <br>
     <br>
     <br>
</div>可以给不同的图片设置多个不同的属性background: url(img_flwr.gif) right bottom no-repeat, url(paper.gif) left top repeat;CSS3 background-size 属性background-size指定背景图像的大小。CSS3以前,背景图像大小由图像的实际大小决定。CSS3中可以指定背景图片,让我们重新在不同的环境中指定背景图片的大小。您可以指定像素或百分比大小。你指定的大小是相对于父元素的宽度和高度的百分比的大小。<body style="background:url(img/img_flwr.gif);
        background-size:80px 60px;
        background-repeat:no-repeat;
        padding-top:40px;">
<p>
    Lorem ipsum,中文又称“乱数假文”, 是指一篇常用于排版设计领域的拉丁文文章 ,主要的目的为测试文章或文字在不同字型、版型下看起来的效果。
</p>

<p>原始图片: <img src="img/img_flwr.gif"alt="Flowers" width="224" height="162"></p>

</body>CSS3 的 background-origin 属性background-origin 属性指定了背景图像的位置区域。content-box, padding-box,和 border-box区域内可以放置背景图像。CSS3 多个背景图像
CSS3 允许你在元素上添加多个背景图像。
body
{
    background-image:url(img_flwr.gif),url(img_tree.gif);
}CSS3 background-clip属性CSS3中background-clip背景剪裁属性是从指定位置开始绘制。#example1 {
    border: 10px dotted black;
    padding: 35px;
    background: yellow;
    background-clip: content-box;
}


页: [1]
查看完整版本: CSS3 背景