0

I want to make a CSS layout for comments.

So basically a comment block consists of 3 parts:

  1. User photo on the left
  2. Comment header (consisting of user name floated left and comment data floated right)
  3. Comment body (floating user photo)

http://dabblet.com/gist/10660127 this is what I have so far. The problem that I cant make a proper comment heading. Obviously I want to align it properly, like if I put many brs after .comment-title (but not the best solution, here I show the desired result: http://dabblet.com/gist/10660333).

Any good solution for that markup?

3 Answers 3

1

You need to add clear: both (or maybe clear: right, depending on how it behaves with the avatar image) to your body class.

You can give it some padding-top, too.

Sign up to request clarification or add additional context in comments.

1 Comment

It almost worked. Look what I have: oi58.tinypic.com/zn1uuo.jpg . The problem is that the comment text is also floating the comment title or kind of. I tried to add margins but it didn't work properly :(
0

I believe you're just looking to float user-photo left? Here's what I came up with real quick: http://dabblet.com/gist/10661017

3 Comments

I have float:left in .user-photo. I want the data to be floated to right, and when I do it the main text goes between comment title and data
Instead of floating it right you can use a margin-left like this: dabblet.com/gist/10661626
Not sure if you got me right, but the Grim... answer looks the right one. Look what I want: dabblet.com/gist/10661782 . After adding clear:right to the body class I have by comment title (username + date) the way I want to.
0

Separate left content from right content explicitly: user-photo | user-info.

Apply margin-left: width(.user-photo) + some px

Make .title display: table

See example in Fiddle

HTML:

<div class="user-photo"></div>
<div class="user-info">
    <div class="title">
        <h3 class="pull-left">User name</h3>
        <h3 class="pull-right">11.02.2014</h3>
    </div>
    <div class="body">  
    Aenean vel ornare sapien. Suspendisse cursus pulvinar mattis. Donec magna odio, feugiat sed blandit vitae, fermentum eget ante. In iaculis nulla pretium malesuada porttitor. Ut adipiscing purus at pulvinar ultricies. Vestibulum lacinia erat felis, vitae faucibus justo dictum quis. Proin at erat ut turpis mollis aliquet. Aenean ornare nunc non elit sodales bibendum. Donec ac blandit turpis. Nunc faucibus in sapien in vehicula. Sed quam arcu, bibendum in imperdiet consequat, suscipit quis metus. In non est porttitor, adipiscing justo vitae, tempus nisi.
    </div>  
</div>

Diff CSS:

.comment .user-info {
    margin-left: 120px;
}

.comment .title {
    display: table;
    width: 100%;
}

1 Comment

This is great except that I wanted to comment text really float the picture like oi62.tinypic.com/mucqkl.jpg here. I've already tried to break the comment into two parts using margin-left but in this case the text won't actually float the picture

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.