• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
成为自己最想成为的那种人
博客园    首页    新随笔    联系   管理    订阅  订阅
CSS样式属性——背景

 背景——包括背景颜色、背景图片,以及背景图片的控制

    background-color:设置背景色(transparent表示透明的背景色)

    background-image:设置元素的背景图片    background-repeat:确定背景图片是否以及如何重复

               no-repeat:只出现一次  repeat:在水平和垂直方向上重复  repeat-x和repeat-y分别在水平和垂直方向上重复

    background-attachment:确定背景图像是否跟随内容滚动(fixed表示固定,scroll表示图像跟随内容的移动而移动)

    background-position:指定背景图像的水平位置和垂直位置(水平:left,center,right,数值  垂直:top,center,bottom,数值)

  3个Div在同一区域分层:

    <head>

      <title></title>

      <style type="text/css">

        div{

          height:300px;

          width:300px;

        }

        div.div1{

          background-color:red;

          top:100px;

          left:100px;

          position:absolute;    //absolute表示绝对定位

          z-index:3;         //z-index值越高的显示在外面

        }

        div.div2{

          background-color:yellow;

          top:130px;

          left:130px;

          position:absolute;

          z-index:2;

        }

        div.div3{

          background-color:green;

          top:160px;

          left:160px;

          position:absolute;

          z-index:1;

        }

      </style>

    </head>

    <body>

      <div class="div1"></div>

      <div class="div2"></div>

      <div class="div3"></div>

    </body>

  右下角固定弹窗:

    <style type="text/css">

      .div1{

        right:0px;

        bottom:0px;

        background-color:yellow;

        position:fixed;

        height:250px;

        width:350px;

      }

    </style>

    ……

    <div class="div1"></div>

posted on 2017-05-03 17:50  遇见未来  阅读(202)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3