Syntax

Description: align is defined as a helper utility that aligns the element it is applied to relative to its parent element.

ctr('<#selector>', {
align: <align:value>
})
<#selector>:
align: <align:value>
<#selector> {
<...>: <...>;
}

Notes

Bottom

Description: The value of 'bottom' centers the element horizontally at the bottom of the parent element.

Edit
ctr('.test', {
width: 200px
align: 'bottom'
})
.test:
width: 200px
align: bottom
.test {
bottom: 0;
left: 50%;
top: auto;
right: auto;
width: 200px;
position: absolute;
transform: translate(-50%, 0);
}
ctr('.test', {
  width: 200px
  align: 'bottom'
})
.test {
  bottom: 0;
  left: 50%;
  top: auto;
  right: auto;
  width: 200px;
  position: absolute;
  transform: translate(-50%, 0);
}
.test:
  width: 200px
  align: bottom

Notes

Bottom Left

Description: The value of 'bottom-left' aligns the element at the bottom left corner of the parent element.

Edit
ctr('.test', {
width: 200px
align: 'bottom-left'
})
.test:
width: 200px
align: bottom-left
.test {
left: 0;
bottom: 0;
top: auto;
right: auto;
width: 200px;
position: absolute;
transform: translate(0, 0);
}
ctr('.test', {
  width: 200px
  align: 'bottom-left'
})
.test {
  left: 0;
  bottom: 0;
  top: auto;
  right: auto;
  width: 200px;
  position: absolute;
  transform: translate(0, 0);
}
.test:
  width: 200px
  align: bottom-left

Notes

Bottom Right

Description: The value of 'bottom-right' aligns the element at the bottom right corner of the parent element.

Edit
ctr('.test', {
width: 200px
align: 'bottom-right'
})
.test:
width: 200px
align: bottom-right
.test {
right: 0;
bottom: 0;
top: auto;
left: auto;
width: 200px;
position: absolute;
transform: translate(0, 0);
}
ctr('.test', {
  width: 200px
  align: 'bottom-right'
})
.test {
  right: 0;
  bottom: 0;
  top: auto;
  left: auto;
  width: 200px;
  position: absolute;
  transform: translate(0, 0);
}
.test:
  width: 200px
  align: bottom-right

Notes

Center

Description: The value of 'center' centers the element both vertically and horizontally.

Edit
ctr('.test', {
width: 200px
align: 'center'
})
.test:
width: 200px
align: center
.test {
top: 50%;
left: 50%;
right: auto;
bottom: auto;
width: 200px;
position: absolute;
transform: translate(-50%, -50%);
}
ctr('.test', {
  width: 200px
  align: 'center'
})
.test {
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  width: 200px;
  position: absolute;
  transform: translate(-50%, -50%);
}
.test:
  width: 200px
  align: center

Notes

Center Left

Description: The value of 'center-left' centers the element vertically at the left side of the parent element.

Edit
ctr('.test', {
width: 200px
align: 'center-left'
})
.test:
width: 200px
align: center-left
.test {
left: 0;
top: 50%;
right: auto;
bottom: auto;
width: 200px;
position: absolute;
transform: translate(0, -50%);
}
ctr('.test', {
  width: 200px
  align: 'center-left'
})
.test {
  left: 0;
  top: 50%;
  right: auto;
  bottom: auto;
  width: 200px;
  position: absolute;
  transform: translate(0, -50%);
}
.test:
  width: 200px
  align: center-left

Notes

Center Right

Description: The value of 'center-right' centers the element vertically at the right side of the parent element.

Edit
ctr('.test', {
width: 200px
align: 'center-right'
})
.test:
width: 200px
align: center-right
.test {
right: 0;
top: 50%;
left: auto;
bottom: auto;
width: 200px;
position: absolute;
transform: translate(0, -50%);
}
ctr('.test', {
  width: 200px
  align: 'center-right'
})
.test {
  right: 0;
  top: 50%;
  left: auto;
  bottom: auto;
  width: 200px;
  position: absolute;
  transform: translate(0, -50%);
}
.test:
  width: 200px
  align: center-right

Notes

Top

Description: The value of 'top' centers the element horizontally at the top of the parent element.

Edit
ctr('.test', {
width: 200px
align: 'top'
})
.test:
width: 200px
align: top
.test {
top: 0;
left: 50%;
right: auto;
bottom: auto;
width: 200px;
position: absolute;
transform: translate(-50%, 0);
}
ctr('.test', {
  width: 200px
  align: 'top'
})
.test {
  top: 0;
  left: 50%;
  right: auto;
  bottom: auto;
  width: 200px;
  position: absolute;
  transform: translate(-50%, 0);
}
.test:
  width: 200px
  align: top

Notes

Top Left

Description: The value of 'top-left' aligns the element at the top left corner of the parent element.

Edit
ctr('.test', {
width: 200px
align: 'top-left'
})
.test:
width: 200px
align: top-left
.test {
top: 0;
left: 0;
right: auto;
bottom: auto;
width: 200px;
position: absolute;
transform: translate(0, 0);
}
ctr('.test', {
  width: 200px
  align: 'top-left'
})
.test {
  top: 0;
  left: 0;
  right: auto;
  bottom: auto;
  width: 200px;
  position: absolute;
  transform: translate(0, 0);
}
.test:
  width: 200px
  align: top-left

Notes

Top Right

Description: The value of 'top-right' aligns the elements at the top right corner of the parent element.

Edit
ctr('.test', {
width: 200px
align: 'top-right'
})
.test:
width: 200px
align: top-right
.test {
top: 0;
right: 0;
left: auto;
bottom: auto;
width: 200px;
position: absolute;
transform: translate(0, 0);
}
ctr('.test', {
  width: 200px
  align: 'top-right'
})
.test {
  top: 0;
  right: 0;
  left: auto;
  bottom: auto;
  width: 200px;
  position: absolute;
  transform: translate(0, 0);
}
.test:
  width: 200px
  align: top-right

Notes

Example

Description: Locations of the align values.

bottom
bottom-left
bottom-right
center
center-left
center-right
top
top-left
top-right

Notes