Answers for "css style center"

CSS
10

css center

/* this will center all children within the parent element. */
.parent {
  display: flex;
  justify-content: center; /* horizontal */
  align-items: center; /* vertical */
}
Posted by: Guest on May-17-2020
0

css align center

/* This works wonderfully when you know the size of
the thing you are centering. If you don’t know, or are 
thinking it might change and want to be future proof,
try this: */

.centered {
   position: fixed;
   top: 50%;
   left: 50%;
   /* bring your own prefixes */
   transform: translate(-50%, -50%);
}

/* The translate value for transform is based off the size
of the element, so that will center nicely. */
Posted by: Guest on February-19-2021
1

center css

div.container4 {
    height: 10em;
    position: relative }
div.container4 p {
    margin: 0;
    background: yellow;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-right: -50%;
    transform: translate(-50%, -50%) }
Posted by: Guest on April-19-2021

Browse Popular Code Answers by Language