【发布时间】:2018-05-21 17:43:30
【问题描述】:
我想以相同的固定尺寸显示照片(我使用 carieerwave 通过表单添加): articles with image.
这是我的代码:
<div class="section">
<div class="container">
<% @posts.take(4).each do |post| %>
<div class="carda" style="width: 500px; float:left; margin: 20px; height: 430px;">
<div class="card-content">
<%= link_to image_tag(post.image_url, width: 500, height: 250), post %>
<p class="title" style="margin-top: 5px; color:black">
<%= raw link_to post.title, post %>
</p>
</div>
</div>
<% end %>
</div>
</div>
我不知道为什么他们有其他尺寸
【问题讨论】:
-
给出一个完整的 jsfiddle 示例,或者如果您将它托管在某个地方,请提供一个链接进行检查。好像您已经设置了固定宽度
-
@StefanBob 我在服务器上没有它,也不要在 js fiddle 上大喊大叫,因为应用程序使用 Rails,它不会被加载。
-
@derek2 在浏览器中呈现时,您可以将输出的 HTML 粘贴到您的页面上吗?
-
即使不看我也可以说摆脱浮动并放置 display: flex;在你的 .container 上,看看你的宽度是否正常
-
试图刷新浏览器缓存?
标签: html css ruby-on-rails