使用bootstrap 3,我想要一个文章页面来显示所有大小的图像,这些图像既响应又不超过文章边界。这是html:
<div class="col-sm-8">
<div class="article">
<h3 class="title">{{ post.title }}</h3> <ul class="list-inline list-unstyled">
{% if post.author %}
<li class="author">wrote<b>
{{ post.author }} </b>
</li>
{% endif %}
<li class="pubdate">{{ post.pub_date |date:'Y m d' }}
</li>
</ul>
<div class="img-responsive headimage"> <img src="/media/{{post.headimage}}" />
</div>
<div class="open-sans">{{ post.body }}</div>
</div>
</div>
和css:
.headimage img {
max-width: 700px;
padding: 1em;
}
这个限制最大宽度然而是hackish图像没有响应。所以我想知道如何以正确的方式做到这一点。
答案 0 :(得分:4)
防止图像溢出列:
.headimage {
max-width: 100%;
padding: 1em;
}
.headimage > img {
width: 100%;
}