gpt4 book ai didi

html - 如何显示与 rails 内联?

转载 作者:数据小太阳 更新时间:2023-10-29 08:43:56 26 4
gpt4 key购买 nike

我想知道如何“内联”显示我的帖子我开始使用 css,但我不知道我必须将代码 display:inline 放在我的 css 工作表的什么位置。我会尝试 post、main_content、body,但它不起作用。你能解释一下怎么做吗,我遵循了很多教程,结果对我来说从来都不一样,所以我不知道怎么做。

我的实际帖子显示: Actual display

我的代码:索引帖 subview :

<div class="transitions-enabled" id="post">

<%- @posts.each do |post|%>

<div class="row">

<div class="post">


<div class="panel-body">
<div class="form-group text-center">
<h3> <%=post.title%></h3>
</div>
</div>

<div class="box panel panel-default">
<div class="image_wrapper">
<%= link_to (image_tag post.image.url(:medium), class: 'img-responsive'), post_path(post)%>
</div>
</div>

<div class="panel-body">
<div class="form-group text-center">
<p><%= post.prix %></p>
</div>
</div>


</div>
</div>

<%end%>
</div>

&我的应用程序CSS:

@import "bootstrap-sprockets";
@import "bootstrap";

@mixin box-shadow {
-webkit-box-shadow: rgba(0, 0, 0, 0.09) 0 2px 0;
-moz-box-shadow: rgba(0, 0, 0, 0.09) 0 2px 0;
box-shadow: rgba(0, 0, 0, 0.09) 0 2px 0;
}

$red: #DB6161;

body {
background: rgb(235, 238, 243);
}

.main_content {
padding: 0 0 50px 0;

}

.alert {
padding: 15px;
margin-bottom: 20px;
border: 1px solid transparent;
border-radius: 5px;
@include box-shadow;
background: white;
font-weight: bold;
}


.navbar {
margin-bottom: 50px;
@include box-shadow;
border: none;
.navbar-brand {
text-transform: uppercase;
letter-spacing: -1px;
font-weight: bold;
font-size: 25px;
a {
color: $red;
}
}
}

.post {
background: white;
border-radius: 5px;
margin-bottom: 40px;
@include box-shadow;
float: left;


.image_wrapper {
width: 400px;
height: 300px;
border-radius: 5px 5px 5px 5px;
overflow: hidden;
}
img {
width: 100%;
-webkit-transition: all .3s ease-out;
-moz-transition: all .3s ease-out;
-o-transition: all .3s ease-out;
transition: all .3s ease-out;
&:hover {
transform: scale(1.075);
}
.panel-body {
padding: 35px;
h1 {
margin: 0 0 10px 0;
}
.description {
color: #868686;
line-height: 1.75;
margin: 0;
}
}
}
h2 {
padding: 15px 5%;
margin: 0;
font-size: 20px;
font-weight: normal;
line-height: 1.5;
a {
color: $red;
}
}
}

#post_top {
margin-bottom: 50px;
}

#post_info, #ingredients, #directions {
background: white;
@include box-shadow;
min-height: 360px;
border-radius: 5px;
padding: 2em 8%;
}

.post_image {
max-width: 100%;
border-radius: 5px;
@include box-shadow;
}

#post_info {
h1 {
font-size: 36px;
font-weight: normal;
color: $red;
}
.description {
color: #8A8A8A;
font-size: 20px;
}
}

#ingredients, #directions {
margin-bottom: 50px;
ul, ol {
padding-left: 18px;
li {
padding: 1em 0;
border-bottom: 1px solid #EAEAEA;
}
}
}

.form-inline {
margin-top: 15px;
}
.form-input {
width: 65% !important;
float: left;
}
.form-button {
float: left;
width: 30% !important;
margin-left: 5%;
}
.add-button {
margin-top: 25px;
}

最佳答案

除了 CSS 样式之外,您遇到的问题是您在每个帖子周围添加了一个 row 类。

假设你想在每一行显示三个帖子,这样做:

<%- @posts.each_slice(3) do |posts| %>
<div class="row">
<%- posts.each do |post|
...
<% end %>
</div>
<% end %>

更新:刚刚意识到原始代码示例没有显示,尽管这已被标记为答案。已更新以显示示例。

或者只是将 .row div 移动到我们的 each block 之外,这会将所有帖子放在一个 .row 中。

关于html - 如何显示与 rails 内联?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37955737/

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