【发布时间】:2021-11-30 17:05:18
【问题描述】:
我一直试图在 CSS 中将 4 个框和一个链接放在一起,3 个在一行中,2 个在第一个下方,如下所示:Assignment example,但到目前为止我有这个Issue
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
display: grid;
grid-gap: 100px;
grid-template-columns: 200px 200px 200px;
}
a {
padding: 5px;
background-color: blue;
text-decoration-line: none;
color: white;
}
#one {
border-style: solid;
order: 4;
border-width: 5px;
border-color: blue;
box-sizing: border-box;
width: 200px;
height: 130px;
margin: 5px;
padding: 5px;
}
#two {
border-style: solid;
order: 1;
border-width: 5px;
border-color: green;
box-sizing: border-box;
width: 200px;
height: 110px;
margin: 5px;
padding: 5px;
}
#three {
border-style: solid;
order: 0;
border-color: orange;
border-width: 5px;
box-sizing: border-box;
width: 200px;
height: 150px;
margin: 5px;
padding: 5px;
}
#four {
border-style: solid;
order: 3;
border-color: yellow;
border-width: 5px;
box-sizing: border-box;
width: 200px;
height: 110px;
margin: 5px;
padding: 5px;
}
<div id="one">
Turns out you have a really fun time if you go to work every day and focus on being silly and funny and happy! - Hannah Murray
</div>
<div id="two">
All you need in this life is ignorance and confidence, and then success is sure. - Mark Twain
</div>
<div id="three">
Well, if crime fighters fight crime and fire fighters fight fire, what do freedom fighters fight? They never mention that part to us, do they? - George Carlin
</div>
<div id="four">
Great minds discuss ideas; average minds discuss events; small minds discuss people. - Eleanor Roosevelt
</div>
<p id="link">
<a href="https://www.brainyquote.com/" target="_blank">
Brainy Quote</a>
</p>
如何使绿色和蓝色框对齐? 我在做什么错?我知道带有填充和边距的整个盒子模型,但我无法准确理解我应该如何对齐它们。
【问题讨论】: