在某些情况下,我是一个全新的编程新手,只学了大约两个小时的HTML/CSS教程,所以除了您在这里看到的代码之外,我不知道很多元素、属性等.如果我的术语不准确,请原谅,但希望这是有意义的.
我在一节课结束时做了一个练习,试图匹配一个设计,并试图消除我的第一段行和第二段行之间的空白.如您所见,我已经try 将页边距、行高和填充更改为零(我能想到的任何值),但间距仍然存在.
在本练习的解决方案代码中,我看到老师 Select 更改针对所有段落的下边距,而不是特定的段落类.我想了解为什么这会奏效,但针对特定的段落类别并不影响页边距.我想我稍后会明白这一点,但在我明白之前,我会犹豫继续前进.
My code个
<style>
p {
font-family: arial;
}
.price {
font-size: 36px;
}
.currency {
margin-left: 12px;
font-size: 16px;
color: gray;
margin-bottom: 0px;
line-height: 0px;
padding-bottom: 0;
}
.change {
padding-top: 0;
margin-top: 0;
color: green;
font-size: 16px;
line-height: 0;
}
.after-hours {
color: gray;
}
.after-hours-change {
color: red;
}
</style>
<p class="price">1,049.61<span class="currency">USD</span></p>
<p class="change">+18.05 (1.75%) today</p>
<p class="after-hours">After hours 1,048.00
<span class="after-hours-change">-1.61 (0.15%)</span></p>
The teacher's solution code个
<style>
p {
font-family: Arial;
margin-top: 0;
margin-bottom: 0;
}
.price {
font-size: 32px;
margin-bottom: 5px;
}
.currency {
font-size: 16px;
color: rgb(100, 100, 100);
}
.change {
color: rgb(24, 128, 56);
margin-bottom: 8px;
}
.after-hours {
color: rgb(100, 100, 100);
}
.after-hours-change {
color: rgb(235, 39, 39);
}
</style>
<p class="price">
1,049.61 <span class="currency">USD</span>
</p>
<p class="change">
+18.05 (1.75%) today
</p>
<p class="after-hours">
After hours 1,048.00
<span class="after-hours-change">-1.61 (0.15%)</span>
</p>