gpt4 book ai didi

css - rails : Upload images and align as a gallery

转载 作者:太空宇宙 更新时间:2023-11-04 07:17:15 25 4
gpt4 key购买 nike

我正在从我开发的 Rails 应用程序上传图片,在 edit form 中,当前上传的图片仅显示在一行中: enter image description here

这是我的设置:

 <div class="container-image">
<% @attachments.each do |attachment| %>
<div class="item-image">
<div class="pinImage">
<%= image_tag(attachment.image.url(:mini))%>
<p style="font-size: 13px;">
<%= link_to "Remove", remove_item_attachment_path(attachment),
data: { confirm: "Are you sure?"},
:method => :delete %></p>
</div>
</div>
<% end %>
</div>

这是CSS:

.pinImage img
width: 100%
height: auto
border: 1px solid #d9d9d9
border-radius: 6px
background-color: white


.container-image
max-width: 1200px
display: flex
align-items: center
-webkit-justify-content: center
/* Safari */
justify-content: center


.item-image
padding: 5px
display: block

但我希望图像像下面这样对齐显示为图库。知道如何解决这个问题吗?

enter image description here

最佳答案

试试这个更新后的 CSS。添加了 flex-wrap: wrap; 并从 container-image div 中删除了 justify-content:center。同时从正文中删除默认边距。

 
body {
margin: 0;
}
.pinImage img {
width: 100%;
height: auto;
border: 1px solid #d9d9d9;
border-radius: 6px;
background-color: white;
}

.container-image{
max-width: 1200px;
display: flex;
flex-wrap: wrap;
align-items: center;
}

.item-image{
display: block;
width: 25%;
}
 <div class="container-image">
<div class="item-image">
<div class="pinImage">
<img src=""/>
<p style="font-size: 13px;">
delete
</p>
</div>
</div>
<div class="item-image">
<div class="pinImage">
<img src=""/>
<p style="font-size: 13px;">
delete
</p>
</div>
</div>
<div class="item-image">
<div class="pinImage">
<img src=""/>
<p style="font-size: 13px;">
delete
</p>
</div>
</div>
<div class="item-image">
<div class="pinImage">
<img src=""/>
<p style="font-size: 13px;">
delete
</p>
</div>
</div>
<div class="item-image">
<div class="pinImage">
<img src=""/>
<p style="font-size: 13px;">
delete
</p>
</div>
</div>
<div class="item-image">
<div class="pinImage">
<img src=""/>
<p style="font-size: 13px;">
delete
</p>
</div>
</div>
<div class="item-image">
<div class="pinImage">
<img src=""/>
<p style="font-size: 13px;">
delete
</p>
</div>
</div>
<div class="item-image">
<div class="pinImage">
<img src=""/>
<p style="font-size: 13px;">
delete
</p>
</div>
</div>
<div class="item-image">
<div class="pinImage">
<img src=""/>
<p style="font-size: 13px;">
delete
</p>
</div>
</div>
</div>

关于css - rails : Upload images and align as a gallery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50622931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com