背景图片

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>背景图片</title>
    <style>
        .box {
            width: 300px;
            height: 300px;
            background-color: orangered;
        }

        .box {
            /*显示比屏幕大的图片:缩放尺寸*/
            /*background-image: url("img/kj.gif");*/
            /*尽量只设置宽,高等比缩放,不失真*/
            /*background-size: 300px 300px;*/
        }

        .box {
            /*显示比屏幕小的图片:处理平铺与位置*/
            background-image: url("img/lss.jpg");
            /*平铺: repeat-x repeat-y repeat no-repeat*/
            background-repeat: no-repeat;
            /*位置*/
            /*1.只设置x轴,y轴默认center*/
            /*2.x轴:left center right 具体像素 百分百*/
            /*2.y轴:top center bottom 具体像素 百分百*/
            background-position: center center;
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>

相关文章:

  • 2022-02-07
  • 2022-02-07
  • 2022-02-07
  • 2021-10-09
  • 2021-12-04
  • 2022-01-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-07
  • 2021-10-27
  • 2021-09-06
  • 2021-08-29
  • 2021-11-24
相关资源
相似解决方案