我對html和css很新,剛剛開始大約一週前。但是,無論我在哪個顯示器上查看網站,我都有一些問題會讓頁面的寬度適合屏幕。我試過background-size: cover;
,width: 100%;
等。我知道有些事我沒有想到。單頁設計遇到問題
其次,這聽起來真的很愚蠢,有沒有一種方法可以添加沒有內容的頁面長度?
對不起,如果這些都是簡單的問題,我一直在尋找一些答案。下面是我的代碼,如果任何人有任何建議,可以幫助單頁設計,請讓我知道!
謝謝!
HTML
<!doctype html>
<a name="totop" />
<head>
<meta charset="utf-8">
<title> Jack Johnson</title>
<!-- Import CSS Stylesheets Here -->
<link rel="stylesheet" type="text/css" href="file:///C:/users/Jack/desktop/projects/mysitecss.css">
<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="first-page">
<p class="header">Jack Johnson</p>
<p class="subheader">Marketing and Design Specialist</p>
<div id="nav-button">
<a href="#topage2" class="smoothScroll"><center>Scroll Down</center></a></div>
</div> <!-- End of first page -->
<div id="second-page">
<a name="topage2" />
<p class="Quote">I've got a degree in marketing and an aptitude for design.</p>
<p class="P1">Test text 2.</p>
<div id="nav-button2">
<a href="#topage3" class="smoothScroll"><center>Scroll Down</center></a></div>
</div> <!--End of second page-->
<div id="third-page">
<a name="topage3" />
<div id="nav-button3">
<a href="#totop" class="smoothScroll"><center>Go to Top</center></a>
</div>
</div><!--End of third page-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="file:///C:/users/Jack/desktop/projects/smoothscroll.js"></script>
</body>
</html>
CSS
html {background-color: #ffffff; background-size: cover; size: 100%; overflow-x: hidden;}
body {font-family: 'Alegreya Sans', sans-serif;}
.smoothScroll {font-size: 18px; text-decoration: bold; color: #000000; position: absolute; top: 15%; left: 8%;}
#first-page {background-color: #ffffff; position: relative; background-size: cover; padding-bottom: 48%;}
.header {font-size: 65px; position: absolute; top: 36%; left: 36%; color: #000000; }
.subheader {font-size: 40px; position: absolute; top: 46%; left: 35.5%; color: #a5a5a5;}
#nav-button{display:block; border-radius: 25px; width: 95px; height: 30px; background-color: #a5a5a5; position: absolute; top: 96%; left: 48%; opacity:.5;} #nav-button:hover{background-color: #a5a5a5; opacity:1.0; -moz-transition: opacity 500ms linear; }
a:link {text-decoration:none;}
#second-page {background-repeat: no-repeat; background-color: #4761fe; position:relative; top: 4%; background-size: 100%; padding-bottom: 39.5%; margin-left: -2%; margin-right: -2%;}
.Quote {font-size: 60px; color: #ffffff; position: relative; bottom: 3%; left: 2%;}
.P1 {font-size: 23px; color: #ffffff; position: relative; top: 50%; left: 50%;}
#nav-button2{display:block; border-radius: 25px; width: 95px; height: 30px; background-color: #ffffff; position: absolute; top: 92%; left: 48%; opacity:.5;} #nav-button2:hover{background-color: #ffffff; opacity:1.0; -moz-transition: opacity 500ms linear; }
#third-page {background-color: #ffffff; position:relative; backgroud-size: cover; padding-bottom: 44%;}
#nav-button3{display:block; border-radius: 25px; width: 95px; height: 30px; background-color: #a5a5a5; position: absolute; top: 305%; left: 50%; opacity:.5;} #nav-button3:hover{background-color: #a5a5a5; opacity:1.0; -moz-transition: opacity 500ms linear; }
一對夫婦的建議。 ''在第二行不能在那裏,應該是''。每個元素都應該在''或''內,並且這些元素應該位於''的內部。我編輯了你的代碼來反映這一點。此外,我建議您嘗試使用[jsfiddle](http://jsfiddle.com/)在stackoverflow中詢問html/css/javascript,這會讓您的問題更容易回答,從而獲得更多更好的答案。 –