SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: display: table Question

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    70
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    display: table Question

    Hello, I have some questions regarding the CSS display:table; property.

    I want to make a custom responsive wordpress theme, but I have some questions and and looking for suggestions. The problem that I have and other people as well is with certain wordpress plugins that depend on a fixed width sidebar for advertisements, which responsive layouts struggle with. I have been playing around with different things and wanted your opinion on the following proposed solution. I read a story here on sitepoint that praised it, and I have also read things other places that decry the use of table based layouts as a step backwards.

    My idea was to use a simple css table based layout as the overall structure to define sidebars and such and then use a more traditional float based grid system for page content. IE would receive a fixed layout via conditionals.

    HTML Code:
    <!doctype html>
    <html>
        <head>
            <title>Test</title>
            <link rel="stylesheet" type="text/css" media="screen" href="styles.css" />
            <!--[if lt IE 8]> <link rel="stylesheet" type="text/css" media="screen" href="ie.css" /> <![endif]-->
        </head>
        <body>
            <div class="container">
                <div class="wrapper">
                    <div class="row">
                        <div class="fluid">
                            <p>Fusce neque leo, bibendum mollis lobortis non, semper at enim. Quisque venenatis laoreet velit, 
                                ac ullamcorper turpis cursus sed. Donec malesuada sem ac augue rhoncus hendrerit non id elit. 
                            </p> 
                        </div>
    
                        <div class="fixed">
                            <p>sidebar</p>
                        </div>
    
                    </div>
                </div>	
            </div>
        </body>
    </html>
    Code:
    .container {
    	max-width: 960px;
    	margin: 0 auto;
    }
    .wrapper{
    	width: 100%;
    	display: table;
    }
    .row {
    	width: 100%; 
    	display: block;
    }
    .fluid, .fixed {
    	display: block;
    }
    .fixed {
    	background-color: gray;
    }
    
    @media all and (min-width:768px) { 
    	.row{
    		display: table-row;
    	}
    	.fixed {
    		display: table-cell;
    		width: 300px;
    	}
    	.fluid {
    		display: table-cell;
    	}
    }
    I understand that this creates a dependency on source ordering, and that tables have a bad stigma. However, I can't think of another way to accommodate a mix of fixed and fluid elements. Any thoughts?

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2012
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using HTML tables for layouts is COMPLETELY different from using CSS to render elements similarly to tables, regardless of what some people might tell you.

    As long as your HTML is semantic, you can use whatever techniques you want to style it.

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    SitePoint Award Recipient Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    37,796
    Mentioned
    99 Post(s)
    Tagged
    3 Thread(s)
    As Spritanium said its fine to use the display table properties as they infer no semantics upon the actual mark up. They just style it as you want.

    The display:table properties are very useful for certain situations but do bring some of the same problems as tables (cells can't wrap - but that's usually what you want ) but as long as you use them properly they are a great tool for ie8+.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2011
    Posts
    70
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the replies. I've been playing with them for the last few days and they are definitely limited but your right, if they are used correctly then they can be useful.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •