Best way to make Bootstrap responsive based on parent div?

前端 未结 1 1614
抹茶落季
抹茶落季 2020-12-30 05:51

I need a container in bootstrap to be responsive based on the parent div instead of a media query. I can\'t figure out the best way without to do it, particularly without us

相关标签:
1条回答
  • 2020-12-30 06:19

    By using the elementQuery polyfill you should be able to accomplish this. Here is the repo on gitHub, here is an article on Smashing Magazine that explains more about the concept and here is a CodePen the author created to demonstrate how to use it.

    Essentially you use CSS to define breakpoints based on the parent div. Here is an example of the syntax:

    header[min-width~="500px"] {
        background-color: #eee;
    }
    

    Here is a relevant quote from the Smashing Article:

    Introducing the element query. An element query is similar to a media query in that, if a condition is met, some CSS will be applied. Element query conditions (such as min-width, max-width, min-height and max-height) are based on elements, instead of the browser.

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