【发布时间】:2015-11-17 21:06:20
【问题描述】:
在我的 Rails 应用程序上工作,我试图让我的帖子像这样连续 3 个。 (只有在我注释掉 box-sizing、-moz 和 -webkit 时才会发生这种情况;但我留下了一个水平滚动条,我的侧导航与我的帖子图像重叠)]1
我的断点是错误的还是与 box-sizing:border-box 有关?
这是我的 posts.scss 文件
/* Main */
.main{
width: 100%;
height: 100%;
padding-left: 300px;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
position: relative;
z-index: 55;
background: #f6f6f6;
clear: both;}
/* Home/portfolio */
.main .work{
display: block;
//width: 33.33%;
height: auto;
float: left;
position: relative;
overflow: hidden;}
.main .work .media{
width: 100%;
vertical-align: middle;}
.main .work .caption{
//position: absolute;
display: block;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: #ffffff;
opacity: 0;}
.main .work a:hover .caption{
opacity: 1;}
.work .caption .work_title{
display: block;
width: 100%;
position: absolute;
text-align: center;
top: 50%;
margin-top: -40px;}
.main .work .caption h1{
position: relative;
display: inline-block;
max-width: 90%;
padding: 20px 0;
z-index: 77;
color: #454545;
font-family: "raleway-regular", arial;
font-size: 16px;
letter-spacing: .5px;
border-bottom: 1px solid #bfbbbb;
border-top: 1px solid #bfbbbb;}
img.post {
width: 372px;
height: 380px;}
以及我正在使用的响应式代码
@media (max-width:1099px){
header{
display: block;
width: 100%;
min-height: 100px;
padding: 0;
position: relative;
}
header .logo{
margin: 40px 0 0 30px;
float: left;
}
header .footer{
display: none;
}
header #menu_icon,
header .close_menu{
float: right;
margin: 30px 30px 0 0;
}
header nav{
width: 100%;
position: absolute;
top: 100px;
left: 0;
z-index: 9999;
}
header nav ul{
list-style: none;
display: none;
position: relative;
}
header nav ul li a{
display: block;
width: 100%;
padding: 30px 0;
text-align: center;
color: #454545;
font-family: "raleway-regular", arial;
font-size: 14px;
text-decoration: none;
border-top: 1px solid #f7f5f5;
background: #fff;
}
header nav ul li a:active{
background: #f7f5f5;
}
#menu_icon,
.close_menu,
.show_menu{
display: block;
}
.show_menu{
display: block;
}
.main .work{
width: 50%;
}
.main{
width: 100%;
position: relative;
padding-left: 0;
}
#map{
margin: 0!important;
}}
@media (max-width:550px){
.main .work{
width: 100%;
}}
感谢您为我提供的任何帮助!
更新
我的 index.html.erb 文件
<%= render "partials/header" %>
<section class="main clearfix">
<div class="work">
<a href="">
<img src="" class="media" alt=""/>
<h1 class="current-category"><%= params[:category] %></h1>
<% if @posts.count == 0 %>
<h1>There are no Post currently in this category</h1>
<% else %>
<% @posts.each do |post| %>
<a href="/posts/<%= post.id %>">
<%= image_tag post.post_img.url(:post_index), class: "post" %>
</a>
<% end %>
<% end %>
<div class="caption">
<div class="work_title">
</div>
</div>
</a>
我的 _header.html.erb 文件只是装箱
<header>
<div class="logo">
<a href="index.html"><img src="img/logo.png" title="" alt=""/></a>
</div><!-- end logo -->
<div id="menu_icon"></div>
<nav>
<ul>
<li><a href="index.html" class="selected">Home</a></li>
<li><a href="#"><%= link_to "Add Post", new_post_path %></a></li>
</ul>
</nav><!-- end navigation menu -->
</header>
【问题讨论】:
-
能否提供你的html结构??
-
尝试设置链接的字体大小:0。由于此属性,图像元素周围经常出现空白。
-
嗨,感谢@Ilya B. 的建议。但这并没有改变帖子,它仍然和我的第二张照片一样。但我会继续努力,因为我缺少一些简单的东西。
-
我似乎无法在 JSFiddle 中重新创建场景...
-
嘿@Andrew 感谢您的尝试。我认为我的一个 Rails 文件有问题,实际上不是 scss 样式表。所以我只能继续搞砸了。我知道这很简单,我想念大声笑。无论如何,再次感谢您的尝试。
标签: css ruby-on-rails