Search
 
SCRIPT & CODE EXAMPLE
 

CSS

center div scss

/* With FLEX: */
.container {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* With GRID: */
.container {
	display: grid;
	place-items: center
}

/* With plain CSS: */
.center-div {
	margin: auto;
  	width: 50%;
  	aspect-ratio: 1 / 1;
}

/* With positioning: */
.parent{
	position: relative;
}

.parent .center-div {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) '
}
Comment

PREVIOUS NEXT
Code Example
Css :: mat stepper custom css 
Css :: css grid make all rows same height 
Css :: background invisible css 
Css :: how to make border for letters in css 
Css :: bootstrap file upload 
Css :: how bold text in css 
Css :: css button disabled hover 
Css :: css firefox remove scrollbar 
Css :: css border radius top 
Css :: css how to make something italized 
Css :: text gradient css3 
Css :: safari overflow-y scroll not working 
Css :: scroll bar on border radius element css 
Css :: video camera icon font awesome 
Css :: how many fonts can i add in a css font-face 
Css :: how to change another element on hover 
Css :: disable right click with css 
Css :: css grid span columns 
Css :: mat dialog background color 
Css :: css last item should be flex end 
Css :: vertical align text in div bottom 
Css :: css_background_img 
Css :: first child css in material ui 
Css :: change size material checkbox 
Css :: input text size css 
Css :: hide scroll bar but still be scrollable. 
Css :: css background image shown on top right 
Css :: insert background colour to css file 
Css :: how to change the position of a button in css 
Css :: add image under header html 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =