Position की Utilities
Position utilities elements को relative, absolute, fixed, या sticky रखती हैं और इन्हें edges पर pin करती हैं।
In this page:
Syntax
<div class="position-relative">
<div class="position-absolute top-0 end-0">corner</div>
</div>
Position Utilities
.position-static, -relative, -absolute, -fixed, और -sticky इस्तेमाल करें। फिर edge helpers .top-0, .start-0, .end-0, .bottom-0, और .translate-middle element position करते हैं, और .fixed-top, .fixed-bottom, और .sticky-top common shortcuts देते हैं।
Absolute children को एक relative parent चाहिए।
Note:
एक absolute element इसके nearest positioned ancestor के relative position होता है।
उदाहरण: Position utilities
<!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">
</head>
<body class="p-3">
<div class="container">
<div class="position-relative bg-light border" style="height: 8rem">
<span class="position-absolute top-0 start-0 badge text-bg-primary">top-start</span>
<span class="position-absolute top-50 start-50 translate-middle badge text-bg-success">centre</span>
<span class="position-absolute bottom-0 end-0 badge text-bg-danger">bottom-end</span>
</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. #}
आम गलतियां
- एक position-relative parent भूल जाना
- कई elements पर fixed इस्तेमाल करना
- fixed bars से content cover करना
चैप्टर सारांश
- position-relative, absolute, fixed, sticky classes मिलती हैं
- top-0, start-0, end-0, bottom-0 utilities भी मिलती हैं
- translate-middle edge पर centre करता है
- Absolute को एक relative parent चाहिए
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: