Setting the Scene
Imagine a scenario where two divs are placed side by side.
- div1: 500px wide
- div2: taking up the remaining width
The goal is to make the items in div2 responsive using Bootstrap so that classes like mt-sm-3
can be utilized for different screen sizes (xs, sm, lg, xl
), adjusting the margin top accordingly.
However, it's important that the responsiveness is based on the width of the parent div rather than the browser window width.
The Burning Question
Can this be achieved with Bootstrap? If yes, how?
Pondering Options
- Create custom classes for div2 using JavaScript to dynamically add
custom-[xs,sm,lg,xl]
based on size. This workaround seems cumbersome and goes against the simplicity of using a popular CSS framework like Bootstrap. - Insert an iframe within div2 containing Bootstrap styles. However, this solution may complicate matters for projects involving React/Redux.