Dropdowns क्या हैं
Dropdowns एक button click होने पर links का एक menu reveal करते हैं।
In this page:
Syntax
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown">Menu</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Item</a></li>
</ul>
</div>
Dropdowns
data-bs-toggle="dropdown" वाले एक trigger को .dropdown में एक .dropdown-menu list के साथ wrap करें। Directions .dropup, .dropend, या .dropstart से बदली जा सकती हैं, और alignment .dropdown-menu-end से।
Items .dropdown-item इस्तेमाल करते हैं, और dividers और headers इन्हें organise करते हैं।
इसे Popper के साथ JS bundle चाहिए।
Note:
Dropdown बिना extra JavaScript code के काम करता है, सिर्फ bundle चाहिए।
उदाहरण: Dropdowns
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body class="p-3">
<div class="container">
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Actions</button>
<ul class="dropdown-menu">
<li><h6 class="dropdown-header">Edit</h6></li>
<li><a class="dropdown-item" href="#">Rename</a></li>
<li><a class="dropdown-item" href="#">Duplicate</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item text-danger" href="#">Delete</a></li>
</ul>
</div>
</div>
</body>
</html>
Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- data-bs-toggle missing होना
- JS bundle भूल जाना
- menu को dropdown wrapper के बाहर रखना
चैप्टर सारांश
- trigger पर data-bs-toggle="dropdown"
- dropdown-menu और dropdown-item
- dropup, dropend, dropstart variants मिलते हैं
- JS bundle चाहिए
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: