Html5中背景屬性的示例分析-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)Html5中背景屬性的示例分析,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

我們擁有十多年網(wǎng)頁設(shè)計(jì)和網(wǎng)站建設(shè)經(jīng)驗(yàn),從網(wǎng)站策劃到網(wǎng)站制作,我們的網(wǎng)頁設(shè)計(jì)師為您提供的解決方案。為企業(yè)提供成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、微信開發(fā)、微信小程序定制開發(fā)、成都手機(jī)網(wǎng)站制作、html5、等業(yè)務(wù)。無論您有什么樣的網(wǎng)站設(shè)計(jì)或者設(shè)計(jì)方案要求,我們都將富于創(chuàng)造性的提供專業(yè)設(shè)計(jì)服務(wù)并滿足您的需求。

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  背景區(qū)域定位
  border-box: 從border區(qū)域開始顯示背景
 padding-box: 從padding區(qū)域開始顯示背景
 content-box: 從content內(nèi)容區(qū)域開始顯示背景

background-clip 背景繪制區(qū)域
 border-box: 從border區(qū)域開始繪制背景
 padding-box: 從padding區(qū)域開始繪制背景
 content-box: 從content內(nèi)容區(qū)域開始顯示背景

3、背景練習(xí)代碼部分:

<!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 h5{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>
    <p class="container">
      <section>
        <h5>1、background-origin: border-box | padding-box | content-box</h5>
        <ul class="origin">
          <li></li>
          <li></li>
          <li></li>
        </ul>
      </section>
      <section>
        <h5 style="margin-top: 20px;border-top: 1px dashed #ccc;">2、background-clip: border-box | padding-box | content-box</h5>
        <ul class="clip">
          <li></li>
          <li></li>
          <li></li>
        </ul>
      </section>
      <section>
        <h5 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;
</h5>
        <p class="pic"></p>
        <p>注釋:復(fù)合寫background-size的時(shí)候,一定要用/與其他值隔開。</p>
      </section>
    </p>
  </body>
</html>

5、背景練習(xí)preview:

Html5中背景屬性的示例分析

Html5中背景屬性的示例分析



6、漸變:

線性漸變:linear-gradient(方位(left/left top/60deg),起始顏色 | 百分比30%,終止顏色);使用時(shí)加內(nèi)核前綴eg:-webkit-linear-gradient,IE9不支持
徑向漸變:radial-gradient(中心點(diǎn)位置,擴(kuò)散程度,顏色域 | 百分比);由中心向四周發(fā)散,eg:-webkit-radial-gradient(50px 50px,起始顏色,終止顏色);-webkit-radial-gradient(center,起始顏色,終止顏色);
IE低版本兼容:filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#ff0000',GradientType='1');1表示從左到右,0是從上到下,并且顏色值只能是6位哈希值


7、漸變練習(xí)代碼部分:

<!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: 20px auto;
        border: 1px dashed #ccc;
      }
      .container h5{padding-bottom: 5px;}
      .container ul{
        width: 1200px;
        overflow: hidden;
      }
      .container ul.linear li,
      .container ul.filter li{
        width: 600px;
        height: 40px;
        margin: 10px 0;
      }
      .container ul.linear li:first-child{
        background: -webkit-linear-gradient(60deg,#fff 10%, #f00 30%, #0f0 50%, #00f 70%, #000);
      }
      .container ul.linear li:last-child{
        background: -webkit-linear-gradient(left top, rgba(122,156,233,.6) 30%, rgb(255,12,222) 60%, green 80%, #fff);
      }
      .container ul.filter li:first-child{
        background: filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#abcdef',endColorstr='#f44add',GradientType='0');
      }
      .container ul.filter li:last-child{
        background: filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#000000',GradientType='1');
      }

      .container ul.radial li{
        width: 200px;
        height: 200px;
        margin-right: 20px;
        float: left;
        border-radius: 100%;
      }
      .container ul.radial li:nth-child(1){
        background: -webkit-radial-gradient(center, #fff, #000);
      }
      .container ul.radial li:nth-child(2){
        background: -webkit-radial-gradient(left 50px, #fff, #000);
      }
      .container ul.radial li:nth-child(3){
        background: -webkit-radial-gradient(50px 100px,100px 100px, #fff 80%, #000);
      }
      .container ul.radial li:nth-child(4){
        background: -webkit-radial-gradient(left, #fff 20%, #f00 40%, #0f0 60%, #00f 80%, #000);
      }
    </style>
  </head>
  <body>
    <p class="container">
      <section>
        <h5>1、線性漸變:-webkit-linear-gradient(方位,顏色域 | 范圍百分比)</h5>
        <ul class="linear">
          <li></li>
          <li></li>
        </ul>
      </section>
      <section>
        <h5>2、線性漸變-兼容IE低版本:filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='6位哈希值',endColorstr='6位哈希值',GradientType='1/0');</h5>
        <ul class="filter">
          <li></li>
          <li></li>
        </ul>
      </section>
      <section>
        <h5>3、徑向漸變:radial-gradient(中心點(diǎn)位置,擴(kuò)散程度,顏色域 | 百分比);</h5>
        <ul class="radial">
          <li></li>
          <li></li>
          <li></li>
          <li></li>
        </ul>
      </section>
    </p>
  </body>
</html>

8、漸變preview:

Html5中背景屬性的示例分析

關(guān)于“Html5中背景屬性的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯(cuò),請把它分享出去讓更多的人看到。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

網(wǎng)站標(biāo)題:Html5中背景屬性的示例分析-創(chuàng)新互聯(lián)
地址分享:http://bm7419.com/article30/gdspo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、網(wǎng)站改版、網(wǎng)頁設(shè)計(jì)公司、商城網(wǎng)站、網(wǎng)站導(dǎo)航、網(wǎng)站營銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

營銷型網(wǎng)站建設(shè)