Skip to content

Instantly share code, notes, and snippets.

@shahab65
Last active March 1, 2020 08:16
Show Gist options
  • Save shahab65/66af7594c581e069fa04bbb76daeaf6c to your computer and use it in GitHub Desktop.
Save shahab65/66af7594c581e069fa04bbb76daeaf6c to your computer and use it in GitHub Desktop.

how to put element in vertical center of parent?

<div class={"parent"}>
  ...
  <div class={"child"}>
    ...
  </div>
</div>

vertical center:

.parent{
position:relative;
}

.child{
  position: abosolute;
  top:50%;
  transform: translate(-50%, -50%);
 }

both vertical and horiaental:

        position: absolute;
        top: 50%;
        left:50%;
        transform: translate(-50%, -50%);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment