gpt4 book ai didi

html - 填充会使我的整个站点关闭?

转载 作者:太空宇宙 更新时间:2023-11-04 04:03:23 25 4
gpt4 key购买 nike

我正在尝试为学校网站构建 HTML 原型(prototype),但遇到了问题。当我应用填充时:5px;对于我的元素,如 .newscast 或 .photo_gallery,它会使整个站点关闭。它使元素在每一侧都变得更大!填充应该从内部而不是外部插入。尝试向任何嵌套元素添加一些填充,它会发生!我不太确定该怎么做,但我已经包含了我的代码,但没有应用填充。

感谢您的帮助。

HTML:

<!DOCTYPE HTML>

<html>
<head>
<link href="normalize.css" rel="stylesheet" type="text/css">
<link href="grid.css" rel="stylesheet" type="text/css">
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<header>
<div class="header grid_10">
<h1>Dummy Text</h1>
</div>

<div class="main-menu grid_10">
</div>
</header>

<body>
<div class="news_reel grid_5">
<div id="latest_news" class="grid_10">
<h1>Dummy Text</h1>
</div>

<div class="old_news grid_10" id="old1">
<h1>Dummy Text</h1>
</div>

<div class="old_news grid_10" id="old2">
<h1>Dummy Text</h1>
</div>

<div class="old_news grid_10" id="old3">
<h1>Dummy Text</h1>
</div>

<div class="old_news grid_10" id="old4">
<h1>Dummy Text</h1>
</div>
</div>

<div class="right_bar grid_5">
<div class="grid_10" id="newsletter">
<h1>Dummy Text</h1>
</div>

<div class="grid_10" id="photo-gallery">
<h1>Dummy Text</h1>
</div>

<div class="grid_10" id="newscast">
<h1>Dummy Text</h1>
</div>
</div>
</body>

<footer>
<div class="grid_10 footer_bar">
</div>

<div class="grid_10 footer">
<h1>Dummy Text</h1>
</div>
</footer>


</html>

CSS:

.header {
height: 180px;
margin: 0 auto;
background: #e5e5e5;
}

.main-menu {
height: 50px;
margin: 0 auto;
background: #1800ea;
}

.news_reel {
margin: 0 auto;
float: left;
}

#latest_news {
height: 400px;
margin: 0 auto;
background: #c61111;
}

.old_news {
height: 200px;
margin: 0 auto;
}

#old1 {
background: #295f16;
}

#old2 {
background: #2527a1;
}

#old3 {
background: #0da19f;
}

#old4 {
background: #d00aa5;
}

.right_bar {
margin: 0 auto;
}

#newsletter {
height: 400px;
margin: 0 auto;
background: #ed337e;
}

#photo-gallery {
height: 400px;
margin: 0 auto;
background: #65005c;
}

#newscast {
height: 400px;
margin: 0 auto;
background: #ebc800;
}

.footer_bar {
height: 50px;
margin: 0 auto;
background: #1800ea;
}

.footer {
height: 180px;
background: #e5e5e5;
margin: 0 auto;
}

最佳答案

Padding 是默认放大元素的边界。如果你想改变那个用法:

-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */

如果您想使用 <=IE8,请相应地调整框的宽度。

或者,如果您想坚持使用 grid.css,您可以在每个当前 div 中放置一个 div 并设置内部 的边距>divs,但这不是最干净的解决方案。

关于html - 填充会使我的整个站点关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21710953/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com