你好,我是新来的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