重修前端程序员

自适应内部元素

2016-06-07  本文已影响103人  adiu

设计场景


应用场景


我们用一幅图来展示实际的应用场景:

perfect.png

分析:

老式解决方案


<p>文本</p>
<figure>
    <img src="" alt="" width="" height="" />
    <figcaption>标题/描述</figcaption>
</figure>
<p>文本</P>
float.png inline-block.png

新式解决方案


figure {
    max-width: 502px;
    max-width: min-content;
    margin: 20px auto;
}
figure > img {
    max-width: inherit;
}

说明:

《CSS SECRETS》

上一篇 下一篇

猜你喜欢

热点阅读