图像大小不正确

时间:2018-01-10 11:30:52

标签: html css

我正在尝试将3个图像的大小设置为在一行上相同的宽度。最后一个图像是完整大小。它也没有改变它的高度。怎么会?

.activity-snippets {
  display: flex;
}

.activity-post-link {
  height: 215px;
  width: 33.33333333%;
}
<div class="activity-snippets">
  <div class="activity-post-link">
    <img src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
  </div>
  <div class="activity-post-link">
    <img src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
  </div>
  <div class="activity-post-link">
    <img src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
  </div>
</div>

3 个答案:

答案 0 :(得分:4)

尝试将 max-width: 100% 用于 img 标记。使用此图像将采用父容器的宽度

&#13;
&#13;
.activity-snippets {
  display: flex;
}

.activity-post-link {
  height: 215px;
  width: 33.33333333%;
}

img {
  max-width: 100%;
}
&#13;
<div class="activity-snippets">
  <div class="activity-post-link">
    <img src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
  </div>
  <div class="activity-post-link">
    <img src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
  </div>
  <div class="activity-post-link">
    <img src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
  </div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

如果图像大小不改变它可能是因为你在div元素中添加了不在图像中的类。

<div class="activity-snippets">
  <div>
    <img class="activity-post-link" src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
   </div>

  <div>
    <img class="activity-post-link" src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
   </div>

  <div>
    <img  class="activity-post-link" src="https://cdn.dribbble.com/users/476251/screenshots/2619255/attachments/523315/placeholder.png">
  </div>
</div>

答案 2 :(得分:1)

试试这个

&#13;
&#13;
units
&#13;
LSTMCell
&#13;
&#13;
&#13;