Search
 
SCRIPT & CODE EXAMPLE
 

CSS

position absolute center horizontally

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

position absolute horizontally center

/*if you want to align center on left attribute.
The same thing is for top alignment, you could use margin-top: (width/2 of your div), the concept is the same of left attribute.
It's important to set header element to position:relative.
try this:
*/
#logo {
    background:red;
    height:50px;
    position:absolute;
    width:50px;
    left:50%;
    margin-left:-25px;
}

/*If you would like to not use calculations you can do this:*/

#logo {
  background:red;
  width:50px;
  height:50px;
  position:absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
}
Comment

absolute center css

.btn__play {
	position: absolute
    top: 50%
    left: 50%
    transform: translate(-50%, -50%)
}
Comment

center absolute element

.child {
    position: absolute;
    top: 50%;  /* position the top  edge of the element at the middle of the parent */
    left: 50%; /* position the left edge of the element at the middle of the parent */

    transform: translate(-50%, -50%); /* This is a shorthand of
                                         translateX(-50%) and translateY(-50%) */
}
Comment

PREVIOUS NEXT
Code Example
Css :: flex justify-content 
Css :: color code css 
Css :: insert background colour to css file 
Css :: import custom font 
Css :: no break line html 
Css :: @font-face css 
Css :: button highlight none css 
Css :: html css navbar with dropdown 
Css :: font face 
Css :: css for paragraph beautiful 
Css :: text outline in css 
Css :: transition delay only for specific property 
Css :: angular ng-deep 
Css :: make input invisible but clickable css 
Css :: remove contact form 7 css 
Css :: background-size 
Css :: how to make a list vertical in css 
Css :: maximum length for input box 
Css :: centered navigation 
Css :: css blur image without blur borders 
Css :: box shadow to table cell css 
Css :: font awesome center icon vertically and horizontally 
Css :: box glow css 
Css :: bootstrap popover style width 
Css :: brightness css 
Css :: center background image in css 
Css :: scss select all childs 
Css :: css text-decoration 
Css :: cypress element css 
Css :: how to hide text that is longer than its parent div 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =