centering element in css

Table of Contents

.parent{
  position: relative;
}
.child{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

Backlinks

css

Cascading Style Sheets is a markup language with

  • basically all label:value pairs
  • a large set of builtin properties, including colours/patterns, position styles, common functionalitis like scroll, image auto resize… Sometimes stuff that should be done with actually functions, but very common so css include them and browsers render them.
  • a few syntax tweaks like classes/inheritance, class in css - class in html…

Author: Linfeng He

Created: 2024-04-03 Wed 20:20