Skip to content

Why I need to write col-xs-12 if I want full column width on mobile with Flexbox grid? #17603

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

Closed
smajl opened this issue Sep 15, 2015 · 5 comments

Comments

@smajl
Copy link

smajl commented Sep 15, 2015

In v3, every column class (if not specified otherwise with col-xs-? class) was breaking to full width on mobile. In v4 Flexbox version I need to write col-xs-12 manually everywhere to achieve the same thing. Is this by design or bug?

@cvrebert cvrebert changed the title v4 - Why I need to write col-xs-12 if I want full column width on mobile? Why I need to write col-xs-12 if I want full column width on mobile with Flexbox grid? Sep 15, 2015
@matt-hernandez
Copy link
Contributor

It isn't so much with mobile, so much as whenever the screen falls beneath any breakpoint in v3, if there isn't a .col-* class to handle sizing at that point, the columns break to full width. This is because the styling for the width and float disappear at that breakpoint, and the <div> elements snap to their default browser width, which is 100%.

With flex, <div> elements don't break to 100%, and instead behave more like inline-block.

Would it be possible to have flex-basis:100% in the .col-* classes? This could be easier to do if #17228 is implemented.

If not, then @smajl you may have to put col-xs-12 everywhere.

@smajl
Copy link
Author

smajl commented Sep 22, 2015

@matt-hernandez Yeah, I know, with "mobile" I was referring to resolutions <34em rather then to physical device. :) This was not so clear.

Thanks for the explanation of the problem. The "parent" .col class could be the easiest way of solving this in flex grid system. Till then, I'll use my own helper class until the #17228 is decided:

@if $enable-flex {
  @include media-breakpoint-down(xs) {
    .col {
      flex-basis: 100%;
    }
  }
}

@tnoetzel
Copy link

+1 to adding flex-basis: 100% on the .col-* classes.

However, given that this issue also happens at the sm, md, and even lg breakpoints (assuming you use xl), I went with a simpler helper class than @smalj suggested, which handles all those cases and doesn't depend on the .col class:

 [class*="col-"] {
    flex-basis: 100%;
}

@mdo mdo added this to the v4.0.0-alpha.3 milestone Feb 6, 2016
@mdo mdo mentioned this issue Feb 6, 2016
1 task
@mdo
Copy link
Member

mdo commented Feb 6, 2016

Resolved with #17603, which adds auto layout to flexbox grid cols.

@mdo mdo closed this as completed Feb 6, 2016
@mdo
Copy link
Member

mdo commented Feb 6, 2016

Actually, this wasn't "resolved", but the grid behavior has changed and you need the default .col-xs-12 on xs viewports. See #19099 for more details.

stroebjo added a commit to stroebjo/DataTablesSrc that referenced this issue Apr 1, 2016
The flexbox enabled grid in bootstap 4 requires the lowest `.col-` to be set. twbs/bootstrap#17603 (comment)
DataTables pushed a commit to DataTables/Dist-DataTables that referenced this issue Dec 2, 2016
The flexbox enabled grid in bootstap 4 requires the lowest `.col-` to be set. twbs/bootstrap#17603 (comment)

Sync to source repo @014cb111b8284f61d832ac3b6b5f868cbbc08fa5
DataTables pushed a commit to DataTables/Dist-DataTables-DataTables that referenced this issue Dec 2, 2016
The flexbox enabled grid in bootstap 4 requires the lowest `.col-` to be set. twbs/bootstrap#17603 (comment)

Sync to source repo @014cb111b8284f61d832ac3b6b5f868cbbc08fa5
DataTables pushed a commit to DataTables/Dist-DataTables-Bootstrap that referenced this issue Dec 2, 2016
The flexbox enabled grid in bootstap 4 requires the lowest `.col-` to be set. twbs/bootstrap#17603 (comment)

Sync to source repo @014cb111b8284f61d832ac3b6b5f868cbbc08fa5
DataTables pushed a commit to DataTables/Dist-DataTables-Foundation that referenced this issue Dec 2, 2016
The flexbox enabled grid in bootstap 4 requires the lowest `.col-` to be set. twbs/bootstrap#17603 (comment)

Sync to source repo @014cb111b8284f61d832ac3b6b5f868cbbc08fa5
DataTables pushed a commit to DataTables/Dist-DataTables-jQueryUI that referenced this issue Dec 2, 2016
The flexbox enabled grid in bootstap 4 requires the lowest `.col-` to be set. twbs/bootstrap#17603 (comment)

Sync to source repo @014cb111b8284f61d832ac3b6b5f868cbbc08fa5
DataTables pushed a commit to DataTables/DataTables that referenced this issue Dec 2, 2016
The flexbox enabled grid in bootstap 4 requires the lowest `.col-` to be set. twbs/bootstrap#17603 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants