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

首頁 > 開發 > CSS > 正文

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

2024-07-11 08:25:34
字體:
來源:轉載
供稿:網友

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

全屏要素

    全屏的元素及其父元素都要設置height:100% 將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>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 澄迈县| 松原市| 东莞市| 长沙市| 新密市| 股票| 无为县| 美姑县| 盐池县| 平顺县| 绥滨县| 沂源县| 新化县| 衡南县| 保康县| 美姑县| 上高县| 灵丘县| 鹤庆县| 九江市| 缙云县| 岳普湖县| 咸阳市| 胶州市| 始兴县| 文山县| 康保县| 南靖县| 巫溪县| 融水| 阿坝| 元朗区| 襄垣县| 湾仔区| 河间市| 琼海市| 罗江县| 酒泉市| 张家界市| 陵水| 天门市|