首页 > 技术文章 > css样式属性

navyouth 2017-10-10 14:14 原文

1、背景

background-color:背景色

 <div style="width:50px; height:50px; background-color:#F00;">

background-image:背景图

<body>
   <div style="width:100px; height:100px; background-color:#6C3; background-image:url(lx1.png);">
    gyvgvgv
     </div>
</body>

background-repeat:no-repeat不平铺;repeat平铺;repeat-x横向平铺;repeat-y纵向平铺

<body>
    <div style="width:100px; height:100px; background-color:#6C3; background-image:url(lx1.png); background-repeat:no-repeat">
    <!--no-repeat不平铺;repeat平铺;repeat-x横向平铺;repeat-y纵向平铺-->
     </div>
</body>

background-position:调整背景图片位置(repeat:no-repeat);center居中;

<body>
    <div style="width:100px; height:100px; background-color:#6C3; background-image:url(lx1.png); background-repeat:no-repeat; background-position:center">
     </div>
</body>

background-position当设置左右必须有上下位置才起作用

<body>
    <div style="width:100px; height:100px; background-color:#6C3; background-image:url(lx1.png); background-repeat:no-repeat; background-position:left 10px top 10px">
     </div>
</body>

 

推荐阅读