Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

center div in div without flex with position absolute

div.cn {
    position: relative;
    width: 200px;
    height: 200px;
    background: gray;
    text-align: center;
}

div.inner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    -webkit-transform: translate(-50%, -50%);  
    transform: translate(-50%, -50%);   
    background: red;
  
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #center #div #div #flex #position #absolute
ADD COMMENT
Topic
Name
8+9 =