【问题标题】:Fill the Gaps between填补之间的空白
【发布时间】:2013-09-24 12:06:45
【问题描述】:

我希望有人能告诉我如何填补网格视图列表的空白。 下面我插入了我从中获得的所有 CSS 更改。还是想不通来填补空白……

我正在谈论的网格位于主页底部:

http://findout-macau.com

#content .category_grid_view li p.timing { margin:0; padding:0; }
#content .category_grid_view li p.timing span { color:#000; }

#page .category_grid_view {
width: auto;
padding-left:0px;  
}
#content .category_grid_view {
margin:-10 0 20px -15px;
padding:0;
width:650px;
clear:both;
}
#content .category_grid_view li a.post_img {
height:auto;
width:100%;
overflow:hidden;
padding:1%;
}
#content .category_grid_view li a.post_img img {
margin:0 auto;
display:block;
height:auto;
}
#content .category_grid_view li {
background: none repeat scroll 0 0 transparent;
float: left;
list-style: none outside none;
margin: -10 0 20px;
padding: 0 0 0 15px;
position: relative;
width: 140px;
}
#content .category_grid_view li.hr {
display: none;
}
#content {
float: left;
overflow: hidden;
padding-left: 5px;
width: 640px;
}
#content .category_grid_view li a.post_img {
display: block;
margin-bottom: 0;
padding: 0;
background: none repeat scroll 0 0 #FFFFFF;
border: 0 solid #E2DFDF;
box-shadow: 0 0 0 #DDDDDD;
height: auto;
width: 100%;
overflow: hidden;
}
#content .category_grid_view li a.post_img img {
height: auto;
overflow: hidden;
width: 100%;
}
#content .category_grid_view li.featured {
position:relative;
-moz-border-radius:3px;
-webkit-border-radius:3px;
}
#content .category_grid_view li .featured_img {
width:69px;
height:72px;
position:absolute;
left:15px;
top:0px;
text-indent:-9009px;
}
#content .category_grid_view li.featured a.post_img {
border: 0 solid #B1D7E0;
}
#content .category_grid_view li .widget_main_title {
padding-top: 7px;
clear: left;
height: 25px;
overflow: hidden;
background: none repeat scroll 0 0 #EBEBEB;
}
#content .category_grid_view li .rating {
background: none repeat scroll 0 0 #EBEBEB;
display: block;
margin: 0px 0;
padding-bottom: 7px;
padding-top: 7px;
}
#content .category_grid_view li p.review {
background: none repeat scroll 0 0 #EBEBEB;
border-bottom: 10px solid #EBEBEB;
border-top: 1px solid #EBEBEB;
color: #EBEBEB;
margin-bottom: 20px;
padding: 5px 0;
}

【问题讨论】:

    标签: css fill gaps-in-visuals


    【解决方案1】:

    问题在于图像高度。

    如果你设置了

    #content .category_grid_view li a.post_img img { height: 97px }
    

    网格视图会显示得很好,但图像看起来会变形。

    尝试调整图像大小以使其看起来不错,并将高度保持为 97 像素。

    编辑

    @Bdalte 的评论

    尝试将每个元素/产品放入一个 div(假设使用类包装器)并将高度设置为从元素/产品中获得的最大高度。 基于Find out divs height and setting div height 你可以使用这个脚本

    var maxHeight = 0;
    $('div.wrapper')
      .each(function() { maxHeight = Math.max(maxHeight, $(this).height()); })
      .height(maxHeight);
    

    应该是这样的

    【讨论】:

    • 我知道。因为最初网格视图是您建议的方式。我想要的是根据水平或垂直显示有不同的图像高度,而不改变宽度。
    • 我是这里的新手,但据我了解,即使图像更小,这只会使其他 div 拉伸。我对吗?我的目标是制作类似于 pinterest 图片处理的布局。
    • 嗯,现在我明白你真正想要得到什么了,正如你在图片中看到的那样,脚本将“对齐”每家酒店。
    • images.findout-macau.com/2013/09/grid-view-rows-goal.png 在上面的链接中,我正在考虑更像这张图片的东西。感谢您的所有努力......我真的很感激!
    猜你喜欢
    • 2018-07-13
    • 1970-01-01
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 2022-11-30
    • 1970-01-01
    • 2015-08-19
    • 2014-11-21
    相关资源
    最近更新 更多