The current CSS clearing class in core is well, ... not so great :-) It works, but it forces an extra BR in there which isn't too elegant.
The most widely used technique for clearing can be found here: http://www.positioniseverything.net/easyclearing.html
So why not use that? With proper CSS source ordering now and a proper cleanup of code, now let's start refactoring and adding in useful CSS classes :-)
This patch does that, it adds in a useful CSS clearing class (I've used this on multiple sites, browsers, OSes, no problems). I've cleaned up the actual code because it makes use of the Star HTML hack which no longer works in IE7. The code I put in works around this using the underscore hack, which is still valid markup, but only works in WinIE for whatever reason.
And if you don't like this or want to use it on your site, well with CSS files being in an array now, it's easy to turn off defaults.css so go ahead and do that :-)
Patch is backwards compatible with people using the br class="clear" ... but now the BR is not needed.
Comment | File | Size | Author |
---|---|---|---|
#12 | clear_1.patch | 6.55 KB | m3avrck |
#10 | clear_0.patch | 5.56 KB | m3avrck |
#8 | clear.patch | 5.5 KB | m3avrck |
#1 | css_clear.patch | 5.51 KB | m3avrck |
cssclear.patch | 5.31 KB | m3avrck | |
Comments
Comment #1
m3avrck CreditAttribution: m3avrck commentedUpdated patch for HEAD.
Also reintroduced the * html after talking with Steven, I was thinking too hard about that one :-)
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedawesome ted.
Comment #3
m3avrck CreditAttribution: m3avrck commentedFYI, http://www.positioniseverything.net/ where this clearing class technique is borrowed from is certainly considered the definitive resource on cross browser CSS techniques.
Comment #4
drummSince this would be the first IE hack in Drupal core and the technique does come with a section called "A Word Of Warning (this is important!)", this needs another review.
Comment #5
quicksketchI'm not a fan of CSS hacks in any way, but on a large scale deployment I think that this would be the right move for the future. For a couple reasons:
* The current method for using BR tags in combination with clear is a hack, it's just not in the CSS. Instead we're left with dozens or hundreds of BR tags across a site whose purpose is to overcome a shortcoming in nonstandards-compliant browsers.
* We're correcting this problem to make older browser work the way they should. At the very least, we're consolidating all the hacks into one spot, rather than across the entire site in the HTML marukp. As the web becomes more standards-compliant, we'll be glad that we've already designed sites according to w3c specifications.
* This shouldn't affect future browsers that become standards-compliant. Read Steven Wittens (the Bluebeach author) blog on IE7, Drupal, and CSS hacks (http://www.acko.net/blog/the-ie7-myth).
* In my opinion the ugliest hack in the whole group is the IE/Mac hack. However, this browser is nearly entirely dead (thank goodness) and we're only using it to be backwards compatible. This is one of the only 3 "safe" hacks supported on quirksmode.org.
So, after much thought, I also give this +1
Comment #6
frjo CreditAttribution: frjo commentedI concur with quicksketch so +1 from me also. I have used this technique in both Drupal and on other sites and it works really well.
Comment #7
ejort CreditAttribution: ejort commented+1 from me also. Throwing br's everywhere is a MUCH bigger hack IMO than applying this clearing class.
The CSS itself uses standards compliant methods to achieve it's effect so it is forwards compatible.
It only relies on specifically targeted hacks for IE browsers < version 7. Given that these hacks are known to work reliably in the older browsers and are also known be compatible with the upcoming version 7 they should be considered safe.
Comment #8
m3avrck CreditAttribution: m3avrck commentedUpdated for HEAD.
Comment #9
drummI talked with Steven about this and we are both okay with this patch.
Steven suggested calling the new class 'clear-block', which I think is a good idea. The reasoning is that a 'clear' class is useful for the old style behavior (in your own theme of course, and please not on br again). It is a bit more accurate.
Comment #10
m3avrck CreditAttribution: m3avrck commentedSounds good to me, here is a new one freshly updated for HEAD.
Comment #11
drummOne last thing... there is a
<br class="clear">
left in theme_user_filters() in user.module.There are various clears elsewhere, which should be cleaned up at some point, but we don't need them for this patch. I can't find anything else.
Comment #12
m3avrck CreditAttribution: m3avrck commentedOk here's and updated patch with that extra clear removed. I grepped for a bit and I can't locate any other ones.
Should be good now :-)
Comment #13
drummCOmmitted to HEAD. Please document in the theme upgrade docs.
Comment #14
m3avrck CreditAttribution: m3avrck commentedDocs have been updated: http://drupal.org/node/64292#clear
Comment #15
kiz_0987 CreditAttribution: kiz_0987 commentedGreat idea. I was wondering though if "content" in node.tpl also needs a clear-block? That way when I put floated images into a node they get cleared before the links section.
Comment #16
drummPlease post a separate issue for each instance of adding the clearing class.
I've observed node clearing be a problem on the stacked trimmed/full previews.
Comment #17
(not verified) CreditAttribution: commentedComment #18
dharmanerd CreditAttribution: dharmanerd commentedThis causes problems for me as it pushes the content about 500 px down below the tabs (div id="tabs-wrapper" class="clear-block"). Please remove it from the core. Below lists a better method using overflow auto for wrappers.
http://www.sitepoint.com/blogs/2005/02/26/simple-clearing-of-floats/
I used
.clear-block:after {
display: none;
}
in style.css to fix this.
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3
Comment #19
JohnAlbinSteve, if you are having issues with this style, you probably want to open a separate support request. I've been using this method for 4 years and not seen any 500px shifting effects.