twbs / bootstrap

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.
https://getbootstrap.com
MIT License
170.51k stars 78.84k forks source link

Responsive offcanvas placement #38911

Open mef opened 1 year ago

mef commented 1 year ago

Prerequisites

Proposal

Allow one offcanvas component to have different placements based on the screen dimensions.

Solution

Introduce a set of offcanvas-placement classes including breakpoints: .offcanvas-{breakpoint}-{position}, so that one offcanvas would have a different placement based on the current viewport size.

Demo

For example, a <div class="offcanvas offcanvas-bottom offcanvas-md-end"> would be displayed at the bottom on small devices, and to the right as soon as the viewport's size would be medium.

Solution in a smartphone screen:

offcanvas-bottom-md-right

Same offcanvas in a laptop screen:

offcanvas-bottom-md-right-md

Motivation and context

In current Bootstrap 5.3, the available placements of offcanvas are sub-optimal in some screen sizes, in the sense that:

Current .offcanvas-end on a smartphone screen:

offcanvas-right

Current .offcanvas-bottom on a mid-size laptop screen:

offcanvas-bottom

btwitsdevanshu commented 1 year ago

if we can blur the background of offcanvas placement then it would be more eyecatching.

Arvind-Suthar commented 1 year ago

The content inside the offcanvas will call for scrolling in it on smaller screens, using overlay with scrolling is poor web design