Skip to content

Latest commit

 

History

History
56 lines (46 loc) · 1.12 KB

3.2.9 一道css题.md

File metadata and controls

56 lines (46 loc) · 1.12 KB

一道css题

题目要求:
P标签的最大宽度不可以大于H2标签文字宽度的10%
这里应该是P标签的最大宽度由前面的匿名内联元素宽度(就是大字号文字宽度)决定,可参见最后期望效果GIF示意。
H2标签不能失去高度(h2 文字高度+p 标签高度 = h2 标签高度)

HTML结构(不允许修改)

<h2>
IPHONE XR<br>
IS THE FUCKING<br>
BEST EVER MADE
<p>iPhone XR has not been authorized as required by the rules of the Federal Communications Commission. iPhone XR is not, and may not be, offered for sale or lease, or sold or leased, until authorization is obtained.</p>
</h2>


基础CSS样式

h2{
    font-size: 52px;
    font-weight: bold;
    color: #000;
}
p{
    font-size: 12px;
    color: #333;
}
  • 张鑫旭实现:
h2 {
    width: min-content;
    white-space: nowrap;
}
p {
    white-space: normal;
}
  • 出题人的实现:
h2 {
    display: table;
}
p {
    display: table-caption;
    caption-side: bottom;
}

参考