【发布时间】:2016-03-27 05:19:08
【问题描述】:
我在 Flask (Python) 中有一个 for 循环,它为每个帖子创建一个 div,其中包括一个图像。我希望它是一个正方形。 现在是这样写的:
<div class="row">
{% for post in posts.items %}
<div class="col-xs-6 col-sm-4">
{% if post.image %}
<h4 class="col-centered"><a href="{{ url_for('article', slug=post.slug) }}" class="link">
<img src="{{ post.imgsrc }}" height="370px" width="370px" class="img-rounded">
</h4>
{% endif %}
<h3>
<h4><a href="{{ url_for('article', slug=post.slug) }}">{{ post.title }}</a></h4>
</h3>
</div>
问题是:这会将图像拉伸成一个盒子。如何让它裁剪图像?
【问题讨论】:
标签: python html css image crop