Top, Right, Bottom, Left
Shorthand utilities that corresponds to the top , right , bottom , and/or left properties
Class
|
Properties
|
---|---|
top-0 | |
top-1 | |
top-2 | |
top-3 | |
top-4 | |
top-5 | |
top-6 | |
top-7 | |
top-8 | |
top-10 | |
top-12 | |
top-16 | |
top-20 | |
top-24 | |
top-32 | |
top-40 | |
top-48 | |
top-56 | |
top-64 | |
top-72 | |
top-80 | |
top-88 | |
top-96 | |
top-1/2 | |
top-full | |
top-auto | |
end-0 | |
end-1 | |
end-2 | |
end-3 | |
end-4 | |
end-5 | |
end-6 | |
end-7 | |
end-8 | |
end-10 | |
end-12 | |
end-16 | |
end-20 | |
end-24 | |
end-32 | |
end-40 | |
end-48 | |
end-56 | |
end-64 | |
end-72 | |
end-80 | |
end-88 | |
end-96 | |
end-1/2 | |
end-full | |
end-auto | |
bottom-0 | |
bottom-1 | |
bottom-2 | |
bottom-3 | |
bottom-4 | |
bottom-5 | |
bottom-6 | |
bottom-7 | |
bottom-8 | |
bottom-10 | |
bottom-12 | |
bottom-16 | |
bottom-20 | |
bottom-24 | |
bottom-32 | |
bottom-40 | |
bottom-48 | |
bottom-56 | |
bottom-64 | |
bottom-72 | |
bottom-80 | |
bottom-88 | |
bottom-96 | |
bottom-1/2 | |
bottom-full | |
bottom-auto | |
start-0 | |
start-1 | |
start-2 | |
start-3 | |
start-4 | |
start-5 | |
start-6 | |
start-7 | |
start-8 | |
start-10 | |
start-12 | |
start-16 | |
start-20 | |
start-24 | |
start-32 | |
start-40 | |
start-48 | |
start-56 | |
start-64 | |
start-72 | |
start-80 | |
start-88 | |
start-96 | |
start-1/2 | |
start-full | |
start-auto |
Usage
Position values
Arrange elements easily with the edge positioning utilities. The format is {property}-{position}.
Where property is one of:
-
top
- for the vertical top position -
start
- for the horizontal left position (in LTR) -
bottom
- for the vertical bottom position -
end
- for the horizontal right position (in LTR)
Where position is one of:
-
0
- for 0 edge position -
50
- for 50% edge position -
100
- for 100% edge position
<div class="position-relative">
<div class="position-absolute top-0 start-0"></div>
<div class="position-absolute top-0 end-0"></div>
<div class="position-absolute top-1/2 start-1/2"></div>
<div class="position-absolute bottom-1/2 end-1/2"></div>
<div class="position-absolute bottom-0 start-0"></div>
<div class="position-absolute bottom-0 end-0"></div>
</div>
Center elements
In addition, you can also center the elements with the transform utility class .translate-middle
.
This class applies the transformations translateX(-50%)
and translateY(-50%)
to the element which, in combination with the edge positioning utilities, allows you to absolute center an element.
<div class="position-relative">
<div class="position-absolute top-0 start-0 translate-middle"></div>
<div class="position-absolute top-0 start-50 translate-middle"></div>
<div class="position-absolute top-0 start-100 translate-middle"></div>
<div class="position-absolute top-50 start-0 translate-middle"></div>
<div class="position-absolute top-50 start-50 translate-middle"></div>
<div class="position-absolute top-50 start-100 translate-middle"></div>
<div class="position-absolute top-100 start-0 translate-middle"></div>
<div class="position-absolute top-100 start-50 translate-middle"></div>
<div class="position-absolute top-100 start-100 translate-middle"></div>
</div>
Using with components
<button type="button" class="btn btn-primary position-relative me-10">
Mails
<span class="position-absolute top-0 start-full translate-middle badge rounded-pill bg-danger text-white">+99
<span class="visually-hidden">unread messages</span>
</span>
</button>
<button type="button" class="btn btn-dark position-relative me-10">
Marker
<svg width="1em" height="1em" viewBox="0 0 16 16" class="position-absolute top-full start-1/2 translate-middle mt-1 bi bi-caret-down-fill" fill="#212529" xmlns="http://www.w3.org/2000/svg">
<path d="M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z" /></svg>
</button>
<button type="button" class="btn btn-primary position-relative">
Alerts
<span class="position-absolute top-0 start-full translate-middle badge border border-light rounded-circle bg-danger p-2"><span class="visually-hidden">unread messages</span></span>
</button>
Using with a progress bar
You can use these classes with existing components to create new ones. Remember that you can extend its functionality by adding entries to the $position-values variable.
<div class="position-relative m-4">
<div class="progress" style="height: 1px;">
<div class="progress-bar" role="progressbar" style="width: 50%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<button type="button" class="position-absolute top-0 start-0 translate-middle btn btn-sm btn-square btn-primary rounded-circle">1</button>
<button type="button" class="position-absolute top-0 start-1/2 translate-middle btn btn-sm btn-square btn-primary rounded-circle">2</button>
<button type="button" class="position-absolute top-0 start-full translate-middle btn btn-sm btn-square btn-secondary rounded-circle">3</button>
</div>
Responsive
Responsive variations also exist for each inset value. Use the .{position}-{breakpoint}-{value}
for sm, md, lg, xl, and xxl to any existing position
utility.
<div class="top-md-5 ..."></div>