CSS

背景相关的属性

suaxi
2024-03-05 / 0 评论 / 57 阅读 / 正在检测是否收录...
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>背景相关的属性</title>
    <style>
        div {
            width: 400px;
            height: 400px;
            border: 2px solid black;
            font-size: 40px;
            /* 默认值:transparent */
            /* background-color: skyblue; */

            /* background-image: url("../images/touxiang.jpg"); */
            
            /* 设置背景图片的重复方式 */
            /* background-repeat: no-repeat; */
            
            /* 控制背景图片的位置 第一种写法:关键词 */
            /* background-position: center; */
            
            /* 控制背景图片的位置 第二种写法:用具体的像素值 */
            /* background-position: 150px 150px; */

            /* 复合属性 */
            background: skyblue url("../images/touxiang.jpg") no-repeat 150px 150px;
        }
    </style>
</head>
<body>
    <div>孙笑川</div>
</body>
</html>
0

评论 (0)

取消