![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
On a slightly different note: I've always had trouble with the standard box model ignoring padding and borders when accounting for widths, but you can do something like this: div id="container" div id="column_1"> <!-- Set widths and margins-- <div class="inside"><!-- Set padding and borders -- content here </div /div div id="column_2" <div class="inside" content here </div /div ... Now, widths and margins can be set for column_1 and column_2 (which can be floated), and padding and borders can be set for "inside" using a descendant of it's parent. If you adjust padding or borders (which is a common design thing to do), then the width remains the same, you don't have to go back and recalculate widths. Is anyone with me on this, or is there a flaw here? |
#3
| ||||
| ||||
|
|
On 2008-03-24, Jeff <jeff (AT) spam_me_not (DOT) com> wrote: [...] On a slightly different note: I've always had trouble with the standard box model ignoring padding and borders when accounting for widths, but you can do something like this: div id="container" div id="column_1"> <!-- Set widths and margins-- <div class="inside"><!-- Set padding and borders -- content here </div /div div id="column_2" <div class="inside" content here </div /div ... Now, widths and margins can be set for column_1 and column_2 (which can be floated), and padding and borders can be set for "inside" using a descendant of it's parent. If you adjust padding or borders (which is a common design thing to do), then the width remains the same, you don't have to go back and recalculate widths. Is anyone with me on this, or is there a flaw here? No flaw, I'd say that's the best way to set an outer margin width if that's what you want to do. Note that you put the margins on the outer box but the padding, borders and background on the inner one. You also can try CSS3 box-sizing: border-box or -moz-box-sizing: border-box. |
|
Purists will avoid divs that are only there so you can style them but that have no "semantic" meaning but in my opinion that's setting the bar too high. |
|
Sometimes people propose more extensions to CSS to achieve results that can already be achieved using the existing rules and another level of nesting. But if you ask me it's not worth it. Simplicity is more important, and perhaps people underestimate how much more power there is in a simple set of rules if you allow yourself to create a few extra elements to apply them to. |
|
Note also that the order in which elements appear in the source document already dictates a lot about the layout, however you style it: it's not as if content and presentation are completely decoupled. It has become a bit of a mantra to claim that they are or should be but the reality is more subtle. |
#4
| |||
| |||
|
|
Ultimately where I want to go is a very small handful of layouts that can be assembled to achieve whatever look you want. I think this can be done with a slight variant of the above layout (perhaps in 1 to 4 column variants) or perhaps with unused "columns set to display: none". Thanks, I feel better about the path I'm headed down. |
#5
| |||
| |||
|
|
In article <13ug05sj037tsc0 (AT) corp (DOT) supernews.com>, Jeff <jeff (AT) spam_me_not (DOT) com> wrote: Ultimately where I want to go is a very small handful of layouts that can be assembled to achieve whatever look you want. I think this can be done with a slight variant of the above layout (perhaps in 1 to 4 column variants) or perhaps with unused "columns set to display: none". Thanks, I feel better about the path I'm headed down. The other thing you can do is simply grab one of your previous jobs and change the content. This way will have the advantage that the names of the ids and classes, for example, will be reasonably meaningful. |
#6
| |||
| |||
|
|
snip Purists will avoid divs that are only there so you can style them but that have no "semantic" meaning but in my opinion that's setting the bar too high. snip |
#7
| |||
| |||
|
|
I'm a very simple guy and I need to up my skill set. Ever seen my personal site, for my photography, it's really nothing... http://thelimit.com |
#8
| ||||
| ||||
|
|
Ben C wrote: snip Purists will avoid divs that are only there so you can style them but that have no "semantic" meaning but in my opinion that's setting the bar too high. snip A div has no semantic meaning in any case. It's purely structural. As far as nesting goes, I like to follow a sort of "spatial" standard. If I need extra markup to accomplish something visually, I prefer nesting rather than adding loose tags; for example, if I need a fancy corner on something: div class="Module" div class="void" p>Some content</p /div /div rather than: div class="Module" div class="fancy-corner"></div p>Some content</p /div because I like it when the entire structure of that module - sans any styling - collapses into a single spatial box. This is just a personal preference, though. |
|
Also, when you're looking through the markup, it's much easier to read this way (in my opinion) because you can easily see that the extra nested div does not add a sub-structure to the module. |
|
Of course, it's still best to try and minimize extra markup wherever possible (this is often an interesting challenge, too). |
|
Jeremy |
![]() |
| Thread Tools | |
| Display Modes | |
| |