bootstrap 4 animate column width change

后端 未结 2 570
悲哀的现实
悲哀的现实 2021-02-04 08:24

I have two columns like this:

相关标签:
2条回答
  • 2021-02-04 08:52

    I changed the colmn size by using column sizes provided by Bootstrap. For example col-2 to col-1 Then I adjusted the transition to only target the specific type

    .row [class*='col-'] {
        transition: flex 0.5s ease-in-out, max-width .5s ease-in-out;
    }
    
    0 讨论(0)
  • 2021-02-04 09:02

    Since Bootstrap 4 uses flexbox, CSS transition animations don't work unless you use set a numeric flex-grow or flex-shrink on the columns.

    .col-8 {
      flex-grow: 1;
      transition: all 400ms ease;
    }
    
    .col-0 {
      width: 0; 
      flex-shrink: 1;
      transition: all 400ms ease;
    }
    

    Demo: http://www.codeply.com/go/4Un0Q8CvkQ


    To animate the grid columns as they change the media query breakpoints (instead of toggle classes via jQuery), you can simply use a CSS transition on the grid columns.

    .row [class*='col-'] {
        transition: all 0.5s ease-in-out;
    }
    

    Demo: https://www.codeply.com/go/IHUZcvNjPS

    0 讨论(0)
提交回复
热议问题