How would you style this html so that everything falls into a table?


Tags: html,css,positioning,css-tables

Problem :

How would you make the following html fall into a table-like structure where each div.comment_column falls horizontally next to one another? I prefer to use CSS and not tables:

<div class="comments_div">

    <div class="comment_column">
        <div id="comment_title_23" class="comment_title">
            What do you think of the lyrics?
            <a href="/comment_titles/23" class="comment_title_delete" data-method="delete" data-remote="true" rel="nofollow">x</a>
        </div>
        <div class="comment" id="comment_4">
             Great lyrics!
        </div>
    </div>

    <div class="comment_column">
        <div id="comment_title_25" class="comment_title">
            What should my next song be?
            <a href="/comment_titles/25" class="comment_title_delete" data-method="delete" data-remote="true" rel="nofollow">x</a>
        </div>
        <div class="comment" id="comment_4">
             Nice job! Do a another song next.
        </div>
    </div>

    <div class="comment_column">
        <div id="comment_title_26" class="comment_title">
            Feedback
            <a href="/comment_titles/26" class="comment_title_delete" data-method="delete" data-remote="true" rel="nofollow">x</a>
        </div>
        <div class="comment" id="comment_4">
             Awesome stuff... next time rap a little more than sing but still great job.
        </div>   
    </div>

</div>


Solution :

Add these to your css :

.clearfix:after {
    content: ".";
    display: block;
    clear: both;
    visibility: hidden;
    line-height: 0;
    height: 0;
}

.clearfix {
    display: inline-block;
}

html[xmlns] .clearfix {
    display: block;
}

* html .clearfix {
    height: 1%;
}

.comment_colum {
    float: left;
    /* width: 200px; <-- can set a width here */
}

And change :

<div class="comments_div">

to :

<div class="comments_div clearfix">

    CSS Howto..

    How to use Css to make CellList flow Horizontally rather than Vertically? (GWT & CSS)

    How do I convert HTML to inline CSS in Google AppEngine?

    How to scale and center text vertically in a fluid layout? (using CSS)

    How to make fadeIn() and hide() work only for tablet and desktop versions?

    How can i setup multiple sites within a single ASP.Net project?

    How to understand this CSS inheritance (or override, selection)

    How to import a CSS file from an external bundle resource

    How to add vertical gradient using css?

    How to vertically align absolutely positioned images on top of one another?

    jQuery: How do I target the clicked element when they all share the same CSS class?

    How to properly align something that resizes in a specific location

    How can i overlay an 10x10px image on top of another image?

    How to make in CSS an overlay over an image?

    How to align two text boxes on same line with CSS

    how to place two divs side by side

    How to select nth child with css? [duplicate]

    How to get WordPress Twenty Ten theme sub-menus to expand to their contents (CSS)?

    How to vertically align div text?

    How to specify a more specific styling with .css.scss?

    How to move some text down in a li tag?

    How do I center text vertically with css [duplicate]

    how to set !important on a multi value css transform?

    CSS how to target 2 attributes?

    How to set the width of background-color of a div?

    How do I centre align two BTN button within a jumbotron in HTML

    HTML/CSS: How to get the id of sub menu

    How to check a css propert is supported?

    Prestashop - How to edit views [closed]

    How to adjust height of the div base on contents? [duplicate]

    how to tell org-mode to embed my css file on HTML export?