国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > CSS > 正文

CSS實(shí)現(xiàn)全屏切換效果的示例代碼

2024-07-11 08:41:41
字體:
供稿:網(wǎng)友

如何通過CSS使div實(shí)現(xiàn)全屏效果,主要分為圖片橫排展示全屏切換效果和圖片豎排展示全屏切換效果,分享給大家,具體如下:

全屏要素

  1. 全屏的元素及其父元素都要設(shè)置height:100%
  2. 將html、body標(biāo)簽設(shè)置height:100%

(注:height:100%是跟隨其父元素高度變化而變化的)

1.圖片橫排展示全屏切換效果

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>Document</title>  <style>    *{      padding: 0;      margin: 0;    }    html,body{      height: 100%;    }    #container,.sections,.section{      height: 100%;    }    #section0,    #section1,    #section2,    #section3{      background-color: #000;      background-size: cover;      /*讓背景圖片在容器中居中*/      background-position: 50% 50%;      text-align: center;      color: white;    }    #section0{      background-image: url("http://ossweb-img.qq.com/images/lol/web201310/skin/big86000.jpg");    }    #section1{      background-image: url("http://ossweb-img.qq.com/images/lol/web201310/skin/big11000.jpg");    }    #section2{      background-image: url("http://ossweb-img.qq.com/images/lol/web201310/skin/big55000.jpg");    }    #section3{      background-image: url("http://ossweb-img.qq.com/images/lol/web201310/skin/big45000.jpg");    }    .left{      float: left;      width: 25%;    }  </style></head><body>  <div id="container" style="width:400%">    <div class="sections">      <div class="section left" id="section0">        <h3>this is the page</h3>      </div>      <div class="section left" id="section1">        <h3>this is the page</h3>      </div>      <div class="section left" id="section2">        <h3>this is the page</h3>      </div>      <div class="section left" id="section3">        <h3>this is the page</h3>      </div>    </div>  </div></body></html> 

2.圖片豎排展示全屏切換效果

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <title>Document</title>  <style>    *{      padding: 0;      margin: 0;    }    html,body{      height: 100%;    }    #container,.sections,.section{      height: 100%;    }    #section0,    #section1,    #section2,    #section3{      background-color: #000;      background-size: cover;      /*讓背景圖片在容器中居中*/      background-position: 50% 50%;      text-align: center;      color: white;    }    #section0{      background-image: url("http://ossweb-img.qq.com/images/lol/web201310/skin/big86000.jpg");    }    #section1{      background-image: url("http://ossweb-img.qq.com/images/lol/web201310/skin/big11000.jpg");    }    #section2{      background-image: url("http://ossweb-img.qq.com/images/lol/web201310/skin/big55000.jpg");    }    #section3{      background-image: url("http://ossweb-img.qq.com/images/lol/web201310/skin/big45000.jpg");    }  </style></head><body>  <div id="container">    <div class="sections">      <div class="section" id="section0">        <h3>this is the page</h3>      </div>      <div class="section" id="section1">        <h3>this is the page</h3>      </div>      <div class="section" id="section2">        <h3>this is the page</h3>      </div>      <div class="section" id="section3">        <h3>this is the page</h3>      </div>    </div>  </div></body></html>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 江北区| 凤台县| 宁乡县| 新丰县| 宜昌市| 靖安县| 中阳县| 台南县| 唐海县| 紫云| 奉节县| 扶风县| 江源县| 鄂州市| 纳雍县| 吉木萨尔县| 黄龙县| 双牌县| 庄浪县| 扶风县| 沭阳县| 屏边| 高密市| 林芝县| 沂南县| 佛教| 太康县| 仲巴县| 年辖:市辖区| 明水县| 东兰县| 韩城市| 文山县| 蓝山县| 垣曲县| 读书| 桂阳县| 隆子县| 达拉特旗| 汾西县| 松潘县|