Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v4] Why are all col classes 'position: relative'? #25254

Closed
liquidvisual opened this issue Jan 10, 2018 · 21 comments · Fixed by #28517
Closed

[v4] Why are all col classes 'position: relative'? #25254

liquidvisual opened this issue Jan 10, 2018 · 21 comments · Fixed by #28517

Comments

@liquidvisual
Copy link

Is there a reason for making all columns relative?

Typically I wrap my rows and cols inside 'sections' which have their own padding top and bottom. I sometimes choose to make elements inside those columns stick absolutely to the edges of the section. With cols as relative now, it's less trivial to do so.

Applying an override of..

[class*='col'] {
    position: static;
}

does the trick, and I can't seem to find any drawbacks. Although I'm wondering if there's a good reason for relative in the first place? Please correct me if I'm wrong or missing something.

Cheers!

@liquidvisual liquidvisual changed the title Why are all col classes 'position: relative'? [v4] Why are all col classes 'position: relative'? Jan 10, 2018
@mdo
Copy link
Member

mdo commented Jan 10, 2018

Do you have a demo of the problem you're facing?

@liquidvisual
Copy link
Author

liquidvisual commented Jan 10, 2018

It's not really a problem, it's just a question for the reasoning behind it. If it's to accompany a z-index elsewhere or squash some browser bug somewhere, I can understand why that would be relevant - but I'm trying to find why it's there and not static by default.

@liquidvisual
Copy link
Author

I've put together a quick pen to show a use case. I generally expect my parent blocks and wrappers to have priority for positioning.

https://codepen.io/liquidvisual/pen/OzQYXe

@mdo
Copy link
Member

mdo commented Jan 10, 2018

Honestly can't recall—was hoping your live example would jog my memory :). Looking at v4's and v3's source code, it's there in both, but I'm unsure if I can track it fully in our history.

@mdo
Copy link
Member

mdo commented Jan 10, 2018

Welp, found it, but no answers: 0f17f9b. I imagine it's safe to remove? Dunno how many folks have built with it in mind already...

@liquidvisual
Copy link
Author

Cheers for looking into that. Assuming it's safe, I'll apply the override in my own codebase then.

I'm trying to think of a scenario where someone might have used relative columns for something. Maybe in a case where they hacked a set of columns to have a certain height so they could do the same as my demo. Or they're doing something tricky with z-indexes..

That's all I can think of right now.

If it's not serving any purpose, having a blank positioning context for the columns would be beneficial I reckon.

@mdo
Copy link
Member

mdo commented Jan 10, 2018

If it's not serving any purpose, having a blank positioning context for the columns would be beneficial I reckon.

Agreed. I'll open a PR and start to get some feedback. Thanks for asking and for the example!

mdo added a commit that referenced this issue Jan 10, 2018
Prompted by #25254, I dug into our Git history to see why we add `position: relative` to our grid classes and mixins. Turns out, I have no idea and added it to v3 in a commit that fixed an unrelated issue—see 0f17f9b.
@mdo
Copy link
Member

mdo commented Jan 10, 2018

PR opened: #25255.

@asyncdesign
Copy link

If I'm not mistaken, position: relative was added to grid columns to facilitate absolute positioning of elements within columns. If the relative positioning is removed, then users would need a nested container with relative positioning to wrap elements using top, left, bottom, right, etc. and absolute positioning.

@mdo
Copy link
Member

mdo commented Jan 11, 2018

@asyncdesign Yup, I know how it could be used with that, but there's nothing in the history that shows this was intentional on my part.

If the relative positioning is removed, then users would need a nested container with relative positioning to wrap elements using top, left, bottom, right, etc. and absolute positioning.

It wouldn't require a nested container—it'd require folks to add it manually with custom CSS or our .position-relative utility. Not removing it means folks have to override our code.

@liquidvisual
Copy link
Author

Any update on this?

@TeqGreg
Copy link

TeqGreg commented Jun 29, 2018

I too am having to override this, another use case we are experiencing is the use of a calendar picker within a column- in a form.
When these columns have overflow added, the absolute positioned calendar picker gets 'stuck' in the column since it moves to the closest relative parent, that of the column, rather than my intention within the form wrapper (so you don't have to scroll to fill out a popup modal within a column)

mdo added a commit that referenced this issue Jul 8, 2018
Prompted by #25254, I dug into our Git history to see why we add `position: relative` to our grid classes and mixins. Turns out, I have no idea and added it to v3 in a commit that fixed an unrelated issue—see 0f17f9b.
@perpetual-hydrofoil
Copy link

perpetual-hydrofoil commented Aug 31, 2018

Somewhat related -- you can absolutely position to the bottom of a bootstrap column, but the column itself doesn't fill 100% vertical space; could probably resolve it with .flex-fill or .flex-grow-1 but you'd have to probably move away from .container / .row.

(see positioning of the two red divs):
https://codepen.io/anon/pen/NLdxeq

@mdo
Copy link
Member

mdo commented Sep 17, 2018

Checking in on this, the one holdup I have for it is that this breaks our custom form validation styles when using tooltips: http://getbootstrap.com/docs/4.1/components/forms/#tooltips. I think this might have to wait until v5 to avoid breaking things.

Thoughts @andresgalante?

@rmacklin
Copy link
Contributor

Just discovered an ugly UI issue from this because positioned elements affect the stacking of elements. A recent change added a couple of col- elements which, when the page content was long enough, unintentionally stacked on top of another element that was supposed to be stacked above it. Glad to know there wasn't a specific reason for these to be position: relative so that we can safely override it in our application.

@XhmikosR XhmikosR removed the has-pr label Nov 4, 2018
@mdo mdo added the v5 label Dec 17, 2018
@gavin310
Copy link

gavin310 commented Mar 9, 2019

Setting a column to relative positioning should be at the discretion of the developer. Having every column set to position: relative is counter to the purpose of relative positioning.

@mdo
Copy link
Member

mdo commented Mar 10, 2019

Yup, agreed.

We'll be dropping the relative from columns in v5, just need to make sure we're considering the change to other components as mentioned in my last comment. <3

@gavin310
Copy link

Yup, agreed.

We'll be dropping the relative from columns in v5, just need to make sure we're considering the change to other components as mentioned in my last comment. <3

Awesome! Good to hear.

@zebapy
Copy link

zebapy commented Jan 7, 2020

FWIW I figured the position: relative was set so the push/pull classes in v3 worked correctly.

@ffoodd
Copy link
Member

ffoodd commented Jan 7, 2020

@mdo Be aware that the .stretched-link utility documentation was mentionning that card component was using position: relative (at least in v4) so there is probably something to update if this is getting merged.

@tjbulick
Copy link

thank you all guys for this thread, i'm a happy user of v4 from 2022, and anyway overriding yours position: relative with my own the same one, knowing that yours was made on an intent of solving several local problems

p.s. looking forward to use v5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.