1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need a small Help with CSS

Discussion in 'CSS' started by Abhik, Jul 1, 2009.

  1. #1
    Hello,
    I need a small help to place two div tags horizontally side by side, like the image below.
    The two divs (COMMENTS and Number of Comments) and side by side and wrapped in another div tag.

    [​IMG]

    But, this is what I am getting

    [​IMG]

    Here is the CSS I am using

    .full-art-comments-hdr {
        margin-top: 10px;
        padding-top: 10px;
        padding-right: 5px;
        padding-bottom: 10px;
        border-top-width: 6px;
        border-top-style: solid;
        border-top-color: #CA0003;
        height: 21px;
        border-bottom-width: 1px;
        border-bottom-style: solid;
        border-bottom-color: #CCCCCC;
        margin-bottom: 10px;
    }
    .full-art-comment-hdr-left {
        float: left;
        text-align: left;
        clear: both;
    }
    
    .full-art-comment-hdr-right {
        float: right;
        text-align: right;
        clear: right;
    }
    Code (markup):
    and here is the php code

    <div class="full-art-comments-hdr">
    <div class="full-art-comment-hdr-left"><h3>COMMENTS</h3></div>
    <div class="full-art-comment-hdr-right"><h4><?php comments_number('no responses','one response','% responses'); ?></h4></div>
    </div>
    Code (markup):
    Please help me to get it like the first image

    ~ digitech
     
    Abhik, Jul 1, 2009 IP
  2. KnuTz

    KnuTz Well-Known Member

    Messages:
    169
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    130
    Digital Goods:
    1
    #2
    try applying overflow:hidden to the parent div (full-art-comments-hdr)
     
    KnuTz, Jul 1, 2009 IP
    Abhik likes this.
  3. Abhik

    Abhik ..:: The ONE ::..

    Messages:
    11,337
    Likes Received:
    606
    Best Answers:
    0
    Trophy Points:
    410
    Digital Goods:
    2
    #3
    Thanks.. But that hides the COMMENT div (full-art-comment-hdr-left). I need to show them both.
     
    Abhik, Jul 1, 2009 IP
  4. KnuTz

    KnuTz Well-Known Member

    Messages:
    169
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    130
    Digital Goods:
    1
    #4
    how about a link to your site ? also try removing clear:both and clear:right on the child divs
     
    KnuTz, Jul 1, 2009 IP
  5. dynashox

    dynashox Premium Member Staff

    Messages:
    8,662
    Likes Received:
    563
    Best Answers:
    3
    Trophy Points:
    335
    #5
    Add margin-top under 'full-art-comment-hdr-left' and play with the value for it.

    - Dynashox -
     
    dynashox, Jul 1, 2009 IP
  6. Abhik

    Abhik ..:: The ONE ::..

    Messages:
    11,337
    Likes Received:
    606
    Best Answers:
    0
    Trophy Points:
    410
    Digital Goods:
    2
    #6
    Nope.. its not working dynashox.. :(
     
    Abhik, Jul 1, 2009 IP
  7. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Those two things being floated in both directions normally would give you what you want. The reason it isn't now is they're both clearing. Why are you doing that?

    Remove clear from BOTH of those things... if there's a point later in the page where they are clearing other floats above them, then move that clear to their container (always makes more sense to me to have containers do the clearing than floated children inside them).
     
    Stomme poes, Jul 2, 2009 IP
  8. justinlorder

    justinlorder Peon

    Messages:
    4,160
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The basic html and css code are below .
    <div id="contain">
    <div class="left">aaaaa</div>
    <div class="right">aaaaa</div>
    <br style="clear: both" />
    </div>


    #contain {
    width:768px;
    }
    .left {
    margin:0;
    float:left
    width:384px;
    }
    .right {
    margin:0;
    float:left
    width:384px;
    }

    You can modify it if necessary .
     
    justinlorder, Jul 3, 2009 IP
  9. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #9
    Not that one should EVER be using presentational classnames (left, right) or wasting their time on a clearing break in this day and age.

    As to OP's code, mein gott that's made of /FAIL/ - you have perfectly good block level containers in the form of the heading tags, so what the **** are they wrapped in DIV for? NOT that Either of those actually LOOK like headings to a section, though I'd have to see where it's used on the page. I'm fairly certain the 'h4' is NOT a heading to a subsection. (I smell tag abuse)

    ASSUMING that since you have it all in a DIV called header, I'm going to say throw away ALL of the DIV since that's a single heading entity. I'm also going to assume you have a div wrapping the whole comments section called #fullArtComments.

    <h3>
    	<span>COMMENTS</span>
    	<?php comments_number('no responses','one response','% responses'); ?>
    </h3>
    Code (markup):
    Which would make the CSS a simple:

    #fullArtComments h3 {
    	overflow:hidden; /* wrap floats */
    	zoom:1; /* trip haslayout, wrap floats in IE */
    	margin:10px 0;
    	padding:10px 5px 10px 0;
    	text-align:right; /* positions the responses */
    	border-top:6px solid #CA0003;
    	border-bottom:1px solid #CCC;
    }
    
    #fullArtComments h3 span {
    	float:left;
    }
    Code (markup):
    Though I'd have to see the WHOLE code to be certain since I'm guessing on the parent container. I would NOT fix the height of that section since it would make wordwraps made of /FAIL/.


    Hope this helps.
     
    deathshadow, Jul 3, 2009 IP