css background 属性详解

<html>
    <header>
        <title>css background 属性详解</title>
    </header>
    <style>
        .bg{
            width: 500px;
            height: 400px;
            /**
            backgound 的参数
                1.颜色(background-color)
                2.图片(background-image)
                3.重复(background-repeat) 
                        repeat:垂直和水平方向重复,默认值
                        repeat-x:水平方向重复
                        repeat-y:垂直方向重复
                        no-repeat:不重复
                        inherit(继承):background-repeat属性设置从父元素继承
                4.背景图片固定/滚动(background-attachment)
                        scroll:随着页面滚动(默认)
                        fixed:不滚动
                        local:背景图片会随着元素内容的滚动而滚动
                        initial(最初的):保持最初的
                5.位置(background-position)
                        left top/left center
                        center
                        x% y% 
                        xpos xpos
                        inherit(继承)
            其余
                background-clip:背景绘制区域
                        border-box:背景绘制在方框内(默认值)
                        padding-box:背景绘制在衬距方框内
                        content-box:背景绘制在内容方框内
                background-origin(原点):指定background-position属性应该是相对位置
                        border-box:背景图像边界框的相地位置
                        padding-box:背景图像填充框的相对位置
                        content-box:背景图像相对位置的内容框
                background-size:背景图象的大小
                        20px 20px
                        20% 20% 
                        cover 保持纵横比,缩放成指定区域最小大小
                        contain 保持纵横比,缩放成指定区域最大大小
            **/
            background: #00ff00 url('https://www.runoob.com/try/demo_source/smiley.gif') repeat fixed center;
            background-clip:border-box;
            padding:20px;
            border:30px solid red;
        }
    </style>
    <body>
        <div class="bg"></div>
    </body>
<html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值