我正在研究一個非常基本的網站模板,在左上角有一個固定的標題,在左下角和右下角有一個固定的底線。居中Div元素垂直
中間的內容應該是居中,我不能完全弄清楚我做錯了什麼。
問題1)如果我刪除了height: 100%
css屬性,爲什麼垂直居中不起作用?
問題2)當在html標籤上聲明height: 100%
時,爲什麼網站大於100%並超出了瀏覽器窗口?
問題3)爲什麼bottom-left
顯示正確,但不是bottom-right
?
問題4)如果將with設置爲100%並且文本對齊到右側,那麼文本不會從右側瀏覽器框架開始並延伸到左側?爲什麼它擴展瀏覽器窗口?
非常感謝您的幫助。代碼如下
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
html {
height:100%;
}
body {
height: 100%;
margin-left: 20px;‚
}
.title {
position: absolute;
top: 20px;
font-family: serif;
font-size: 20px;
text-align: left;
}
/* Center Text Section */
.area {
width: 100%;
height: 100%;
position: relative;
}
.middlespace {
position: absolute;
left: 50%;
top: 50%;
display: table;
}
.middlespace p {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.exhibitionindex {
text-align: center;
width: 500px;
margin-right: auto;
margin-left: auto;
}
.bottom-left {
position: absolute;
bottom: 15px;
text-align: left;
}
.bottom-right {
position: absolute;
bottom: 15px;
text-align: right;
}
.exhibitiontitle {
color: #d4d4d4;
font-style: italic;
font-family: sans-serif;
font-size: 10px;
text-align: center;
}
.bold {
font-family: serif;
}
.about {
font-size: 11px;
}
.contact {
font-size: 11px;
}
.openinghours {
font-style: italic;
color: #8e8e8e;
font-size: 11px;
}
</style>
<title>Website Title</title>
</head>
<body>
<div class="title">Logo/Title Text</div>
<div class="area">
<div class="middlespace">
<p>27. April 2012</p>
</div>
</div>
<div class="bottom-left">
<span class="about"><span class="bold">XYZ</span> is a project by Person One, Person Two, Person Three | </span>
<span class="contact">Website Information — <a href="mailto:[email protected]">[email protected]</a></span>
</div>
<div class="bottom-right"><span class="openinghours">Opening Hours Information</span></div>
</body>
</html>
首先,您已經有一些額外的大括號。在做其他事情之前,我會先清理它們。 –
謝謝傑夫!照顧那些。 – Roland
This:'營業時間Information/span'沒有正確關閉。 – Zuul