gpt4 book ai didi

html - 在 html 中填充文章元素

转载 作者:行者123 更新时间:2023-12-02 16:08:02 24 4
gpt4 key购买 nike

我正在使用文章标题来划分我希望显示的一些元素:

.project-elem {
background-color: greenyellow;
padding-top: 5rem;
padding-bottom: 5rem;
height: 300px;
}

.projects {
margin: 0;
padding: .7rem;
background-color: #DDCDE8;
font: Asap, sans-serif;
height: 1000px;
}

.project-n {
background-color: green;
text-align: center;
width: 60%;
float: left;
padding: 2.5rem;
}

.img {
background-color: blue;
text-align: center;
padding: 3rem;
margin-left: 40%;
}
<div class="projects" id=#projects>
<h2>My Projects</h2>
<article class="project-elem">
<div class="project-n" id="dictocounter">
<h3>Dictation Counter</h3>
<p>info about proj</p>
<img src="dictocounter1.jpg" alt="Dictocounter in Action">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="calc">
<h3>RPN Calculator</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="RPN Calculator Decoding Input">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="markov">
<h3>Markov Chain Text Generation</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="Markov Chain Text Generation">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="audio">
<h3>Song Similarities</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="Audio Spectral Analysis">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
<article class="project-elem">
<div class="project-n" id="tree">
<h3>DFS/BFS Search Tree</h3>
<p>info about proj</p>
<img src="calc.jpg" alt="Simple Trees">
</div>
<div class="img">
<p>heres SOME IMAGE</p>
</div>
</article>
</div>

然而,即使我显式地填充了 project-elem,实际的 project-elem 文章并没有被填充(相反,所有的东西都混成了一个浅绿色的 Blob ) :

enter image description here

我可以看出元素元素之间没有填充,因为在每个石灰绿色元素元素之间看不到外部分隔(bkgrd 颜色为紫色)。为什么会这样,我该如何解决?

此外,我怎样才能使 img 类垂直 - 即使是 project-n 类?

最佳答案

您可能需要 margin-bottom 而不是 padding-bottom

通过使用填充,您不会将它们分开,填充的工作方式类似于从内部

你可能会读到盒模型 here理解这一点。

关于html - 在 html 中填充文章元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68836316/

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