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

PREVIOUS NEXT
Code Example
Css :: three dots in css 
Css :: remove boldness css 
Css :: text align left top 
Css :: css contenteditable outline 
Css :: wordpress smooth scroll to anchor 
Css :: css a link remove underline 
Css :: vertically and horizontally center a fixed div 
Css :: css wordwrap 
Css :: css wrap text to next line 
Css :: how to remove background color in css 
Css :: text gradient css 
Css :: remove ul decoration 
Css :: media queries w3schools 
Css :: mat card title center 
Css :: css div on the bottom 
Css :: disable text wrap css 
Css :: how to make image a circle css 
Css :: sass compressed style 
Css :: css make something always on top 
Css :: css set width of a span 
Css :: css hide scroll 
Css :: css border bottom 
Css :: ion-tab-bar transparent 
Css :: give transition on box shadow 
Css :: display none but keep space 
Css :: sticky footer bootstrap 3 
Css :: css space between td 
Css :: responsive font size 
Css :: table td remove padding 
Css :: pointer-events 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =