HTML網頁背景圖很長要有滾動條滑動


1 前言

由於網頁背景圖非常長,然后會出現只顯示當前頁面,后面部分看不到,也不能滑動,開始以為不能滑動應該是沒有加overflow-y: auto(scroll),結果加上去也是無效的。

2 代碼

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">        
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<title>長背景圖測試/title>
<style type="text/css">
        //body里面的屬性min-height是關鍵,網上說直接設置成100vh即可,如果不可以可以自己微調
	body{
		background:url(./images/download_bg.png) no-repeat;
		background-size:100%;
                //方案1
		min-height: 185vh;
                //方案2,本質等價於方案一,如果兩個方案是同時開啟,則會使用高度更小的那個,已測試
                //height:1200px;
	}

	#btn{
		margin-top: 150px;
		text-align: center;
	}	
	

</style>
<body>

<div id="btn">
	<a href=" http://www.cnblogs.com/fanbi">
	<img src="./images/download_btn.png" width="90%" alt="跳轉到某個網頁地址"/></a>
</div>	

</body>
</html>

3 小結

僅作為記錄,如果能幫到看到此篇文章的你,那就更好了。 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM