ShadowMage Posted January 8, 2010 Share Posted January 8, 2010 I have some elements that I want displayed inline but I need to be able to specify a width. Is that how the inline-block display style is supposed to work?I've tried it but it just seems to do whatever it wants. On some pages it's laid out as a block element and on others it's an inline element but the width attribute doesn't work.This one does block elements: echo "<div id='tableHeaders' class='bottomBorder'>\n"; echo "<div class='cellHdr' style='width: 120px;'>Order Date</div>\n"; echo "<div class='cellHdr' style='width: 120px;'>Order Num</div>\n"; echo "<div class='cellHdr' style='width: 400px;'>Order Description</div>\n"; echo "<div class='cellHdr number' style='width: 120px; cursor: pointer;' onclick='toggleValues();'>Value</div>\n";echo "</div>\n"; div.body div.cellHdr { color: #000000; background-color: #CCCCCC; font-family: serif; font-size: 12px; font-weight: bold; vertical-align: top; text-align: left; display: inline-block;}div.body .bottomBorder { border-bottom: 1px solid black;}div.body .number { text-align: right;} This one does the inline elements without the width attribute being set: <div style='display: inline-block; width 120px; border: 1px solid;'>test</div><div style='display: inline-block; width 120px; border: 1px solid;'>test</div><div style='display: inline-block; width 120px; border: 1px solid;'>test</div><div style='display: inline-block; width 120px; border: 1px solid;'>test</div> First, how is the inline-block style supposed to work?Second, how can I get this to work the way I want it to?Thanks,jkloth Link to comment Share on other sites More sharing options...
Ingolme Posted January 8, 2010 Share Posted January 8, 2010 An inline block behave exactly like an <img> element would. Think about anything you would do with an image, that's what you can do with an inline block. The difference is that the <img> element has a default width and height, the size of the block depends on the content until you set the width and height. Link to comment Share on other sites More sharing options...
ShadowMage Posted January 8, 2010 Author Share Posted January 8, 2010 Thanks Ingolme!I had some missing quotes in some of my other elements in my first snippet that was raising havoc but as far as I can tell the second one is clean, yet refuses to show up 120px wide. Link to comment Share on other sites More sharing options...
Ingolme Posted January 8, 2010 Share Posted January 8, 2010 Thanks Ingolme!I had some missing quotes in some of my other elements in my first snippet that was raising havoc but as far as I can tell the second one is clean, yet refuses to show up 120px wide.You're missing a colon ':' here:width 120px; Link to comment Share on other sites More sharing options...
ShadowMage Posted January 8, 2010 Author Share Posted January 8, 2010 You're missing a colon ':' here:width 120px; O jeez! What a stupid mistake! Thanks! Can't believe I missed that. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.