“Центр дивизий горизонтально” Ответ

Центринг дивирования горизонтально

/*<div class="content">This works with any content</div>*/
.content {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
Thowhidul Islam

Центр с CSS

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

Как сосредоточиться на вертикальном и горизонтали

.container{	
	margin: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    -ms-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
  	width: /* Define the width here; */
    height: /* Define the height here; */
}

/*You have to define the width and height! */
Cheerful Chimpanzee

CSS Center

// example 1 
div { display: grid; place-items: center; }

// example 3
div{ display:flex; align-items:center; }

// example 3
div { width: 100%; margin: 0 auto; }
paramjeetdhiman

Как горизонтально центрировать элемент

You can apply this CSS to the inner <div>:

#inner {
  width: 50%;
  margin: 0 auto;
}
Of course, you don't have to set the width to 50%. Any width less than the containing <div> will work. The margin: 0 auto is what does the actual centering.

If you are targeting Internet Explorer 8 (and later), it might be better to have this instead:

#inner {
  display: table;
  margin: 0 auto;
}
It will make the inner element center horizontally and it works without setting a specific width.

Working example here:

#inner {
  display: table;
  margin: 0 auto;
  border: 1px solid black;
}

#outer {
  border: 1px solid red;
  width:100%
}
<div id="outer">
  <div id="inner">Foo foo</div>
</div>
shafeeque

Центр дивизий горизонтально

.inner{
margin: 0 auto;
}
Zarden

Ответы похожие на “Центр дивизий горизонтально”

Вопросы похожие на “Центр дивизий горизонтально”

Больше похожих ответов на “Центр дивизий горизонтально” по CSS

Смотреть популярные ответы по языку

Смотреть другие языки программирования