您的位置:首页 > Web前端 > CSS

使用min-content 制作和图片等宽说明文字

2016-09-14 11:23 330 查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>

figure{
width: min-content;
max-width: 300px; /* 给浏览器一个回退样式 */
margin: auto;

}

figure >img{
max-width: inherit;
}
</style>
</head>
<body>
<div >
<p> this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo</p>
<figure class="content">
<img src="https://img-blog.csdn.net/20160914112338724?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="sishi">

<figcaption>this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo this is a photo</figcaption>
</figure>
</div>

</body>
</html>



使用css 关键字 min-content,使图片和底下的文字一样宽;
若使用 display: inline-block, 上方的文字会塌下来;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  css min-content
相关文章推荐