1、背景属性复习: background-image background-color background-repeat background-position background-attachment

2、新增属性: background-size: background-size:x y;   // 水平 垂直方向的尺寸,像素/百分比/auto/⋯ background-size:cover;  //保持宽高比不变,保证占满盒子,但不保证能看到全部 background-size:contain; //保持宽高比不变,保证看清全图,但可能占不满盒子

多背景: background-image:url(1.jpg),url(2.jpg);

background-origin  背景区域定位      border-box: 从border区域开始显示背景   padding-box: 从padding区域开始显示背景   content-box: 从content内容区域开始显示背景

background-clip 背景绘制区域   border-box: 从border区域开始绘制背景   padding-box: 从padding区域开始绘制背景   content-box: 从content内容区域开始显示背景

3、背景练习:

<!DOCTYPE HTML>
<html>
  <head>
    <title>your title name</title>
    <meta charset="utf-8">
    <meta name="Author" content="Wilson Xu">
    <style type="text/css">
      *{margin: 0;padding: 0;font-family: "Microsoft yahei";}
      a{text-decoration: none;}
      a img{display: block;border: none;}
      li{list-style: none;}
 
      .container{
        width: 1200px;
        padding: 20px;
        margin: 10px auto;
        border: 1px dashed #ccc;
      }
      .container h4{padding-bottom: 5px;}
      .container ul{
        width: 1200px;
        overflow: hidden;
      }
      .container ul li{
        float: left;
        width: 331px;
        padding: 20px;
        height: 240px;
        margin-right: 10px;
        border: 10px solid rgba(10,10,10,.3);
        background: url('images/1.jpg') no-repeat;
        background-size: 371px auto;
      }
      .container ul li:last-child{margin-right: 0;}
 
      .container ul.origin li:nth-child(1){
        background-origin: border-box;
      }
      .container ul.origin li:nth-child(2){
        background-origin: padding-box;
      }
      .container ul.origin li:nth-child(3){
        background-origin: content-box;
      }
 
      .container ul.clip li:nth-child(1){
        background-clip: border-box;
      }
      .container ul.clip li:nth-child(2){
        background-clip: padding-box;
      }
      .container ul.clip li:nth-child(3){
        background-clip: content-box;
      }
 
      section .pic{
        width: 600px;
        height: 400px;
        margin: 20px auto;
        border: 1px dashed #ddd;
        background: url('images/3.jpg') no-repeat center center/auto 200px, url('images/2.jpg') no-repeat center center/auto 300px, url('images/1.jpg') no-repeat center center/auto 400px;
      }
      section p{
        font-size: 14px;
        color: #f01010;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <section>
        <h4>1、background-origin: border-box | padding-box | content-box</h4>
        <ul class="origin">
          <li></li>
          <li></li>
          <li></li>
        </ul>
      </section>
      <section>
        <h4 style="margin-top: 20px;border-top: 1px dashed #ccc;">2、background-clip: border-box | padding-box | content-box</h4>
        <ul class="clip">
          <li></li>
          <li></li>
          <li></li>
        </ul>
      </section>
      <section>
        <h4 style="margin-top: 20px;border-top: 1px dashed #ccc;">3、多背景:background: url('images/3.jpg') no-repeat center center/auto 200px, url('images/2.jpg') no-repeat center center/auto 300px, url('images/1.jpg') no-repeat center center/auto 400px;
</h4>
        <div class="pic"></div>
        <p>注释:复合写background-size的时候,一定要用/与其他值隔开。</p>
      </section>
    </div>
  </body>

</html>

练习代码部分:

h5背景的更多相关文章

  1. H5 背景图片自适应屏幕问题解决办法

    今天也是偶然遇到这个问题的,平成很少用到关于css的内容,就在网上找了很多个方法,最后总结以下几种很实用的方法 方法1: <style> body{ background:url(beij ...

  2. Bootstrap优秀模板-Unify.2.6.2

    这是一个非常老牌的Bootstrap商业模板,全面性和稳定性俱佳,有LandingPage.BussinessPage.AdminPage多种模式,非常推荐用来构建官网.响应式应用Web.管理端Web ...

  3. css3处理sprite背景图压缩来解决H5网页在手机浏览器下图标模糊的问题

    近期在负责一个微信H5 App项目,遇到一个郁闷的问题,手机浏览器查看网页时图标都是模糊的,有锯齿,电脑浏览器显示则是正常.大概知道是分辨率适配等类型的问题,后来网上查找了一些办法.大部分的解决方式都 ...

  4. 安卓微信端打开H5页面背景图被键盘挤压移动位置解决

    问题:在微信端(安卓浏览器也如此)打开的H5登录页面中,点击输入信息,弹出软键盘会挤压背景图片. 本来的body宽高设置body{width:100%,height:100%},不起作用,这样写就会导 ...

  5. 网页背景H5视频自动播放---PC端、移动端兼容问题完美解决方案(IOS、安卓、微信端)

    最近公司官网需要使用视频当做banner背景且自动播放,并且因为是官网需要做到PC端和移动端都可以适配兼容,这些问题很是头疼: 兵来将挡,水来土掩,进过查阅相关技术资料,现已完美兼容PC端和移动端.下 ...

  6. 解决H5页面点击一瞬间出现灰色背景的问题

    H5页面有时会出现点击一瞬间出现灰色背景的问题(ios会,安卓不会),解决方法: 加上样式: -webkit-tap-highlight-color: transparent; 如果以上方法不行,则是 ...

  7. 如何利用h5将视频设置为背景

    我们常常有着将视频作为网页背景的需要,但是在设置时也经常差强人意,今天设置了一下,可以基本达到要求了,可能有些小细节做的不是太好,希望指出来,一起进步 第一步:准备工作 工欲善其事必先利其器,我们首先 ...

  8. 【简抄】h5 新增的几个背景属性和文本属性

    一.背景图像显示: ①background-size:规定背景图像的大小: 值:像素值.百分比.auto.cover.contain ②background-origin :规定背景图像的起始位置: ...

  9. 最全面的H5的背景音效素材(经过实践),分享给你!!!

    个人内心独白: 这两天在为一个H5的页面寻找一些相关音效,茫茫的网络,辣么大,真是想法设法翻遍你,不说废话了,看总结吧哦 方法总结(这才是重点,看这里): 1.如果是部分铃声截取的,我们可以来到铃声之 ...

随机推荐

  1. 玲珑杯 Round #18 A -- 计算几何你瞎暴力

    因为坐标都在1-10之间,因此可暴力求解 #include <iostream> #include <cstdio> #include <cstring> #inc ...

  2. 利用 urandom 生成随机密码

    cat /dev/urandom | LC_ALL=C tr -dc "[:alnum:]" | fold -w 16 |head -3   说明: fold -w 16  指定密 ...

  3. 参考《机器学习实战》高清中文PDF+高清英文PDF+源代码

    机器学习是人工智能研究领域中一个极其重要的研究方向,在现今的大数据时代背景下,捕获数据并从中萃取有价值的信息或模式,成为各行业求生存.谋发展的决定性手段,这使得这一过去为分析师和数学家所专属的研究领域 ...

  4. caioj 1065 动态规划入门(一维一边推3:合唱队形)

    就是最长上升子序列,但是要用n^2的算法. #include<cstdio> #include<algorithm> #define REP(i, a, b) for(int ...

  5. 紫书 例题 9-10 UVa 1626 (区间dp + 输出技巧)

    当前区间f(i, j)分两种情况,一种是s[i]于s[j]符合要求,那么可以转移到f[i + 1][j - 1] 这样答案只会更小或者相等 第二种是直接分成两个部分, 即f[i][j] = f[i][ ...

  6. php获取csv数据无乱码

    <?php //获取csv数据    function csvencode($file){        if(!is_file($file['tmp_name'])){            ...

  7. WP8 学习笔记(002_应用程序结构)

    下图是微软官方给出的WP8应用程序执行顺序: 在App.XAML.CS中,有程序主要步骤的函数 // 应用程序启动(例如,从“开始”菜单启动)时执行的代码 // 此代码在重新激活应用程序时不执行 pr ...

  8. 安卓https

    http://www.tuicool.com/articles/NrmE3e http://blog.csdn.net/guestcode/article/details/50194357 http: ...

  9. Scala学习之爬豆瓣电影

    简单使用Scala和Jsoup对豆瓣电影进行爬虫,技术比較简单易学. 写文章不易,欢迎大家採我的文章,以及给出实用的评论,当然大家也能够关注一下我的github:多谢. 1.爬虫前期准备 找好须要抓取 ...

  10. 18.链表管理内存实现c语言自动释放内存

    运行截图: 创建记录分配的内存地址大小和地址的结构体 struct MEM { void *p; int size; }; 创建管理内存结构体的链表 typedef struct LinkNode { ...