简体   繁体   English

HTML / CSS在我的Rails 4应用中表现得很奇怪(高度不可自定义,等等)

[英]HTML/CSS acting very weird in my Rails 4 app (height not customizable etc)

I have two questions with this post. 我对这个帖子有两个问题。 The first is why does the Toyota Camry act like that? 首先是为什么丰田凯美瑞会这样表现? 在此处输入图片说明

Here's the code: 这是代码:

#posts
    - @posts.each do |post|
        .post
            .post_content
                .title
                    %h2
                        = link_to truncate((post.title), length: 25), post
                %p
                    $
                    = post.price
                .post_image
                    = link_to image_tag(post.image.url), post
                .data.clearfix
                    %p.username
                        Listing by
                        = post.user.name
                    %p.buttons
                        %span
                            %i.fa.fa-comments-o
                            = post.inquiries.count
                        %span
                            %i.fa.fa-thumbs-o-up
                            = post.get_likes.size

The CSS: CSS:

#posts {
    .post {
        width: 20%;
        float: right;
        margin: 1rem 1.5%;
        border: 1px solid #E4E4E4;
        /*height: auto;*/
        .post_image {
            height: auto;
            overflow: hidden;
            img {
                width: 100%;
                border-radius: .3rem .3rem 0 0;
            }
        }
        .post_content {
            margin: 1rem;
            h2 {
                margin: 0;
                font-weight: 100;
                padding: 1rem 5%;
                border-bottom: 1px solid #E4E4E4;
                font-size: 1.5rem;
                a {
                    text-decoration: none;
                    /*color: #333233;*/
                    &:hover {
                        color: #6E58E0;
                    }
                }
            }
            .data {
                padding: .75rem 5%;
                color: #969696;
                .username, .buttons {
                    margin: 0;
                    font-size: 1rem;
                }
                .username {
                    float: left;
                }
                .buttons {
                    float: right;
                    span {
                        margin-left: .5rem;
                    }
                }
            }
        }
    }
}

I think that's everything that's working on the page, but if I'm missing something please let me know. 我认为这就是页面上正在处理的所有内容,但是如果我缺少某些内容,请告诉我。

I've been having a lot of problems with it, trying every way I know how to fix it. 我一直在遇到很多问题,尝试用我知道的方法进行修复。

I also didn't have much success in making the individual post element the same width and height, evenly. 在使各个柱子元素的宽度和高度均匀一致时,我也没有取得太大的成功。 This is the second part to this question. 这是这个问题的第二部分。 I'm trying to get the title, image, etc to be evenly throughout each post. 我正在尝试使标题,图像等在每个帖子中均匀分布。

Any help is appreciated as always. 一如既往地提供任何帮助。 Thanks 谢谢

EDIT: I'm not quite sure what you mean by rendered HTML but is this it 编辑:我不太确定您是什么意思的呈现HTML,但这是它 在此处输入图片说明

Additionally, the same CSS and HTML applied to another part of the page works correctly 此外,应用于页面另一部分的相同CSS和HTML可以正常工作 在此处输入图片说明

尝试将以下行添加到“ #posts .post” CSS中

box-sizing: border-box;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM