很新的網頁設計,我認爲這將是一個好主意,創建一個網站的基本樣機,頭部,段落和粘腳,以確保我有一些基礎知識:)垂直和水平的div居中和高效的css
我想知道如何將.paragraph div垂直以及水平居中以及如果有任何明顯的問題或效率低下,我應該知道的代碼。我只是想確保我可以編寫一個基本的佈局而不會產生壞習慣。
所以我結束了這個CSS:
.head {
margin: auto;
height: 100%;
width: 100%;
background-color: #000;
color:white;
text-align:center;}
body {
background-color:#99C;
}
.h1 {
font-size:50px;
font-family:Georgia, "Times New Roman", Times, serif;
padding:30px;
}
.paragraph {
color:#FFF;
text-align:center;
background-color:#333;
width:35%;
margin:auto;
margin-top:165px;
padding:10px;
}
* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
/* equal to footer height */
margin-bottom: -70px;
}
.wrapper:after {
content: "";
display: block;
}
.site-footer, .wrapper:after {
/* .push must be the same height as footer */
height: 70px;
}
.site-footer {
background: orange;
text-align:center;
font-family:Arial, Helvetica, sans-serif;
font-size:40px;
line-height:70px;
}
這裏是它的外觀:
在此先感謝!
亞當^ h
那麼你的問題到底是什麼?圖像沒有顯示出問題。 –
我相信你會得到一些有用的答案,但我只想補充一點。就高效的代碼而言,每個網站都有所不同。這是應該處理的主要技能,更改代碼以適應每種情況。瀏覽器支持是一件值得考慮的事情,並確保您的代碼在您希望用戶使用的瀏覽器上正常工作。祝你好運,快樂的編碼! – Omega
好,主要是我想知道在本體中垂直居中的段落div,我一直在這裏和其他地方的其他帖子上四處張望,它令我感到驚訝,唯一的解決方案,我可以找到需要添加額外的容器div周圍你想要居中。似乎對我很瘋狂,但無論如何感謝您的幫助! –