繁体   English   中英

使用bootstrap 3时如何强制图像最大宽度?

[英]How to enforce image max-width when using bootstrap 3?

使用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;
}

然而,这限制了最大宽度是图像无响应的黑客。 所以我想知道如何以正确的方式做到这一点。

要防止图像溢出列:

.headimage {
  max-width: 100%;
  padding: 1em;
}

.headimage > img {
  width: 100%;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM