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

首頁 > 開發 > CSS > 正文

CSS實現全屏切換效果的示例代碼

2024-07-11 09:07:56
字體:
來源:轉載
供稿:網友

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

全屏要素

  1. 全屏的元素及其父元素都要設置height:100%
  2. 將html、body標簽設置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>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。


注:相關教程知識閱讀請移步到CSS教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿巴嘎旗| 吉水县| 嘉祥县| 滨海县| 丰县| 县级市| 阿城市| 定南县| 昌吉市| 夹江县| 高雄县| 德化县| 蛟河市| 尼勒克县| 新安县| 吉林省| 长兴县| 麻江县| 德惠市| 高邮市| 无棣县| 腾冲县| 木兰县| 兴安县| 张掖市| 衡南县| 福安市| 子洲县| 健康| 宣恩县| 渭南市| 涡阳县| 屯昌县| 长汀县| 百色市| 家居| 桐乡市| 吴忠市| 灵山县| 木兰县| 建湖县|