你好,我是新來的CSS,並試圖創建一個3列基本網頁。我的HTML如下:CSS的間距/寬度
<!DOCTYPE html>
<html>
<head lang="{{ config('app.locale') }}">
<title>Test Title</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../css/all.css" type="text/css"/>
</head>
<body>
<!--Top masthead of the website-->
<header id="welcome-masthead">
<h1> Sexy Website Header </h1>
</header>
<!--Left portion of the website m-->
<article id="welcome-left-section">
<nav>
<a href="#welcome-masthead">- To Top</a> <br>
<br>
<a href="#welcome-bottom">- To Bottom</a> <br>
</nav>
</article>
<!--Center portion of the website -->
<article id="welcome-center-section">
<div>
<p> Some text in the center section </p>
</div>
</article>
<!--Right portion of the website-->
<article id="welcome-right-section">
<div>
<p> Some text in the right section </p>
</div>
</article>
<footer id="welcome-bottom">
<div>
<p> This is the footer </p>
</div>
</footer>
我創建了一個CSS文件,並已與利潤率和寬度設置玩弄和大部分我已經完全創造了一切,是功能齊全,所有的屏幕分辨率均勻間隔(即放大和縮小並不會顯着改變頁面的外觀)。但是,有一部分(中心部分和右部分之間的差距)越大,頁面縮小越多。我無法找到一種解決方案,將這兩部分「粘」在一起,保持兩者之間的距離爲2em。
我的CSS如下。
#welcome-masthead {
height: 6em;
margin: 2em 5em;
padding-top: 0.1px;
white-space: nowrap;
text-align: center;
background-color: #e8eaed;
}
#welcome-left-section {
float: left;
padding: 0.8em;
margin-right: 2em;
margin-left: 2em;
height: 1000px;
width: 10%;
background-color: #e8eaed;
border: thin,solid,#000000;
}
#welcome-center-section {
padding: 0.8em;
margin-right: 2em;
height: 1000px;
width: 61%;
display: inline-block;
background-color: #e8eaed;
border: thin,solid,#000000;
}
#welcome-right-section {
float: right;
padding: 0.8em;
margin-right:2em;
height: 1000px;
width: 20%;
background-color: #e8eaed;
border:thin,solid,#000000;
}
#welcome-bottom {
width:auto;
height: 5em;
padding: 0.8em;
margin: 2em;
background-color: #e8eaed;
border:thin,solid,#000000;
}
任何幫助表示讚賞!我對CSS很新,所以我很抱歉,如果這是一個愚蠢的錯誤!
正常情況下,您應該使用'class'而不是'id'作爲CSS樣式。此外,你的CSS中有多個錯誤。最後,您可以製作一個JSFiddle,以便我們可以更輕鬆地引用您的案例。 – Raptor