Basic Usage
edge
lets you place elements on the edges of a container. Two conditions must be present for edge
to work flawlessly:
edge
must be used in astack
orrelative
container.- When used in a
stack
, thestack
-ing element must not have paddings.
<div class="stack"> <div class="edge-topright">...</div></div>
<div class="relative"> <div class="edge-topright">...</div></div>
Edges
Top edges
There are four top
edges.
edge-topleft
: Place content at the top left edgeedge-top
: Place content at the top edgeedge-topright
: Place content at the top right edgeedge-topfull
: Place content at the top edge, spanning the full width
<div class="stack"> <div class="edge-topleft">...</div> <div class="edge-top">...</div> <div class="edge-topright">...</div> <div class="edge-topfull">...</div></div>
<div class="relative"> <div class="edge-topleft">...</div> <div class="edge-top">...</div> <div class="edge-topright">...</div> <div class="edge-topfull">...</div></div>
Bottom edges
There are four bottom
edges.
edge-bottomleft
: Place content at the bottom left edgeedge-bottom
: Place content at the bottom edgeedge-bottomright
: Place content at the bottom right edgeedge-bottomfull
: Place content at the bottom edge, spanning the full width
<div class="stack"> <div class="edge-bottomleft">...</div> <div class="edge-bottom">...</div> <div class="edge-bottomright">...</div> <div class="edge-bottomfull">...</div></div>
Bottom Right
<div class="relative"> <div class="edge-bottomleft">...</div> <div class="edge-bottom">...</div> <div class="edge-bottomright">...</div> <div class="edge-bottomfull">...</div></div>
Bottom Right
Left edges
There are four left
edges.
edge-lefttop
: Place content at the left top edgeedge-left
: Place content at the left edgeedge-leftbottom
: Place content at the left bottom edgeedge-leftfull
: Place content at the left edge, spanning the full height
<div class="stack"> <div class="edge-left">...</div> <div class="edge-leftfull">...</div></div>
Left top
Left
Left bottom
Left full
<div class="relative"> <div class="edge-left">...</div> <div class="edge-leftfull">...</div></div>
Right edges
There are two right
edges.
edge-righttop
: Place content at the right top edgeedge-right
: Place content at the right edgeedge-rightbottom
: Place content at the right bottom edgeedge-rightfull
: Place content at the right edge, spanning the full height
<div class="stack"> <div class="edge-righttop">...</div> <div class="edge-right">...</div> <div class="edge-rightbottom">...</div> <div class="edge-rightfull">...</div></div>
Right full
<div class="relative"> <div class="edge-righttop">...</div> <div class="edge-right">...</div> <div class="edge-rightbottom">...</div> <div class="edge-rightfull">...</div></div>
Right full
Manipulating Edge Positions
You can finetune the edge
positions with:
--tx
: changes position on the x-axis--ty
: changes position on the y-axis
Here are a few things to note when manipulating edges:
- Elements on the corner edges have both
--tx
andty
values set to-50%
. - Elements on the
top
,bottom
,left
, andright
edges have either--tx
or--ty
set to-50%
. - Positive values push the element towards the center of the container
- Negative values push the element away from center the container.
Convenient utilities for finer edge control
You can use start
and end
keywords to control the position of the element on the main axis.
Here, start
and end
function like logical properties — so start
moves the element to the left while end
moves the element to the right.
Top Edges
<div class="stack"> <div class="edge-topleft-start">Topleft start</div> <div class="edge-topleft-end">Topleft end</div> <div class="edge-topright-start">Topright start</div> <div class="edge-topright-end">Topright end</div></div>
Topleft start
Topright start
Topleft end
Topright end
<div class="relative"> <div class="edge-topleft-start">Topleft start</div> <div class="edge-topleft-end">Topleft end</div> <div class="edge-topright-start">Topright start</div> <div class="edge-topright-end">Topright end</div></div>
Topleft start
Topright start
Topleft end
Topright end
Bottom edges
<div class="stack"> <div class="edge-topleft-start">Topleft start</div> <div class="edge-topleft-end">Topleft end</div> <div class="edge-bottomright-start">Bottomright start</div> <div class="edge-bottomright-end">Bottomright end</div></div>
Bottomleft start
Bottomright start
Bottomleft end
Bottomright end
<div class="relative"> <div class="edge-topleft-start">Topleft start</div> <div class="edge-topleft-end">Topleft end</div> <div class="edge-bottomright-start">Bottomright start</div> <div class="edge-bottomright-end">Bottomright end</div></div>
Bottomleft start
Bottomright start
Bottomleft end
Bottomright end
Left edges
<div class="stack"> <div class="edge-lefttop-start">Lefttop start</div> <div class="edge-lefttop-end">Lefttop end</div> <div class="edge-leftbottom-start">Leftbottom start</div> <div class="edge-leftbottom-end">Leftbottom end</div></div>
<div class="relative"> <div class="edge-lefttop-start">Lefttop start</div> <div class="edge-lefttop-end">Lefttop end</div> <div class="edge-leftbottom-start">Leftbottom start</div> <div class="edge-leftbottom-end">Leftbottom end</div></div>
Right edges
<div class="stack"> <div class="edge-righttop-start">Righttop start</div> <div class="edge-righttop-end">Righttop end</div> <div class="edge-rightbottom-start">Rightbottom start</div> <div class="edge-rightbottom-end">Rightbottom end</div></div>
<div class="relative"> <div class="edge-righttop-start">Righttop start</div> <div class="edge-righttop-end">Righttop end</div> <div class="edge-rightbottom-start">Rightbottom start</div> <div class="edge-rightbottom-end">Rightbottom end</div></div>