Welcome!

And don't forget to edit your signature & profile.

 

Icon

Statistics

  • Total posts 26797
  • Total topics 4868
  • Total members 6607
  • Our newest member
    tugal94

TOP POSTERS

Comments page

All problems and developments related to (X)HTML-markup and stylesheets are discussed and resolved here.
   

Comments page

Postby Althalos » Wed Sep 09, 2009 5:39 am

I'm trying to make a simple list of comments. I have the following:
Code: Select all
<div class="box">
         <div class="comment-left">
            <img src="images/avatar.jpg" class="avatar-comment" />
         </div>
         <div class="comment-right">Comment one</div>
      </div>
      <div class="box">
         <div class="comment-left">
            <img src="images/avatar.jpg" class="avatar-comment" />
         </div>
         <div class="comment-right">Comment two</div>
   </div>


And I have the following CSS:
Code: Select all
#comments div.box {
   padding: 5px;
   margin: 5px 0;
   background-color: #CCC;
}
.comment-left {
   float: left;
   width: 60px;
}
.comment-right {
   float: right;
   width: 550px;
}


But it doesn't work because the height of div.box equals only one line height.

1) Why doesn't the height of div.box stretch its height?
2) anyone has a better suggestion on how to make the comment list (needs to have room for avatar, message, author & date), or any tutorials?

Thanks
Althalos
Smashing <table>
 
Posts: 47
Joined: Sat Feb 14, 2009 8:54 pm
   

   

Re: Comments page

Postby Simon J. » Wed Sep 09, 2009 7:17 am

1) You have to clear. So do something like that:
CSS
Code: Select all
.clear {
   clear: both;
}

HTML
Code: Select all
<div class="box">
   <div class="comment-left">
      <img src="avatar.jpg" class="avatar-comment" />
   </div>
   <div class="comment-right">
      Comment two
   </div>
   <div class="clear"></div>
</div>


2) I would do this:
CSS
Code: Select all
.comments li {
   padding-bottom: 1em;
   clear: left;
}

.comments .avatar {
   float: left;
}

.comments .message, .comments .meta {
   margin-left: 100px; /* width of the avatar */
}
HTML
Code: Select all
<ol class="comments">
   <li id="comment-1">
      <img class="avatar" src="avatar.jpg" alt="Avatar" />
      <p class="meta">
         <span class="author">John Doe</span>
         <span class="date">2001-05-23</span>
         <a href="#comment-1">#</a>
      </p>
      <p class="message">
         Comment one.
      </p>
   </li>

   <li id="comment-2">
      <img class="avatar" src="avatar.jpg" alt="Avatar" />
      <p class="meta">
         <span class="author">John Doe</span>
         <span class="date">2001-05-23</span>
         <a href="#comment-2">#</a>
      </p>
      <p class="message">
         Comment two.
      </p>
   </li>
</ol>
Simon J.
 
Posts: 8
Joined: Fri Sep 04, 2009 6:28 pm
   

   

Re: Comments page

Postby Andy » Wed Sep 09, 2009 8:49 am

Simon J. wrote:1) You have to clear. So do something like that


Don't introduce markup just to clear floats. Use overflow: hidden on .box instead.
Andy
Smashing <h5>
 
Posts: 1281
Joined: Tue Sep 30, 2008 6:42 pm
Location: Sweden
   

   

Re: Comments page

Postby Simon J. » Wed Sep 09, 2009 10:25 am

@ Andy: Wow! Thats cool! Thanks for mentioning. :D
Simon J.
 
Posts: 8
Joined: Fri Sep 04, 2009 6:28 pm
   

   

Re: Comments page

Postby Althalos » Fri Sep 11, 2009 1:38 pm

Thanks :)
Althalos
Smashing <table>
 
Posts: 47
Joined: Sat Feb 14, 2009 8:54 pm
   

   

Re: Comments page

Postby Ivan Sampedro » Sun Sep 13, 2009 4:20 am

This is a cool page :thumbsup:
Ivan Sampedro
 
Posts: 1
Joined: Sun Sep 13, 2009 4:18 am
   


Return to CSS and (X)HTML



Who is online

Users browsing this forum: No registered users and 1 guest