Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Clearfix is an out-dated hack and unreliable cross-browser.
Regardless of the wisdom of it's use, it shouldn't be hardcoded into modules intended for general use with a variety of themes - it should be left to the theming layer and template customisation provided by end developers.
Comment | File | Size | Author |
---|---|---|---|
#13 | remove-hardcoded-clearfix-1462584-13.patch | 1.05 KB | Pere Orga |
#10 | remove-hardcoded-clearfix-1462584-10.patch | 1.05 KB | valderama |
Comments
Comment #1
kanani CreditAttribution: kanani commentedWell you can always override it by copying field-collection-item.tpl.php to your theme and removing the clearfix there.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedClearfix shouldn't be hardcoded. It should be used only when you need to clear floats, there are no floats in collection item.
And you can always override it in field-collection-item.tpl.php and add the clearfix when needed.
Comment #3
John Pitcairn CreditAttribution: John Pitcairn commentedYes, please remove this. A very typical use would be a collection of images and captions, which you might want to float right as a whole. The clearfix class can be very difficult to override in css for IE7 in particular, and it's irritating having to override a .tpl file just to achieve this.
Comment #4
lloop CreditAttribution: lloop commented+1
Comment #5
markabur CreditAttribution: markabur commentedYeah it's backwards that the theme has to *remove* styling provided by the module. Normally the module should supply basic style-free markup and the theme should add styling on top of that.
And yes, clearfix is irrelevant if you're not using floats. Since Field Collection module doesn't/shouldn't use floats anyway, it shouldn't use clearfix. If the theme adds floats then the theme can add clearfix if needed.
Comment #6
John Pitcairn CreditAttribution: John Pitcairn commentedThere are also two hard-coded clearfixes in module code in addition to the one in template code.
One is in
field_collection_field_formatter_links()
, which adds a clearfixed wrapper div.field-collection-container. This container is added for any formatter.The other is in
field_collection_field_formatter_view()
Comment #7
Tristan Chambers CreditAttribution: Tristan Chambers commented+1 for no clearfixes
I spent an hour trying to figure out why my fields were going all kinds of weird places on the page. It wasn't until I realized that these were set "clearfix" that I was able to fix the problem. This is not only a huge annoyance but a violation of separation of content from presentation!
Comment #8
tisteegz CreditAttribution: tisteegz commented+1 for removing these clearfixes.
I have spent way too long trying to override these styles so that I can layout my field collections how I want. I have added the template to my theme but it's the hard coded clearfixes in the module which are my problem.
Comment #9
valderama CreditAttribution: valderama commented+1 for removing these clearfixes.
Comment #10
valderama CreditAttribution: valderama commentedComment #11
valderama CreditAttribution: valderama commentedComment #12
briannowell CreditAttribution: briannowell commentedBumping this issue. This seems to make perfect sense to me, and I am currently overriding this with a template file. However, it does seem backwards to have to do this. I should only be using templates, it seems, to ADD custom styling, not to remove it.
When will this make it into a release?
Comment #13
Pere OrgaRerolled patch
Comment #14
joegl CreditAttribution: joegl commentedWill the patch work in the latest version?
Comment #15
joegl CreditAttribution: joegl commentedDoes anyone else have a CSS fix? I've tried:
With no luck. The clearfix class still overrides it.
EDIT: Figured it out. The clear is also on the :after pseudo class so you need:
Comment #16
Nabru CreditAttribution: Nabru commentedPatch from #13 worked for me. This should really make it to the final build.
Comment #17
jox CreditAttribution: jox commented+1 please remove the clearfixes from the module.
Comment #18
jox CreditAttribution: jox commentedI needed to get rid of the clearfix in the field-collection-container. This is how I worked around it with css:
The problem is that when a field collection is displayed next to (or around) a floating element, then it will move all following elements after the floating element. In other words, the container with the clearfix might also get affected by elements outside of the container, not only by elements inside it (which is the purpose of a clearfix).
Comment #19
Chris Matthews CreditAttribution: Chris Matthews commentedThe patch from #13 does not apply to the latest 7.x-1.x-dev and is probably too old to reroll, but I went ahead and tagged the issue accordingly.