I have a '와' 'div 태그를 너버' 설정되었습니다 800 픽셀입니다 . # 39, 이 때 크면 있지만브라우저에 너버 800 픽셀입니다 shouldn& 스트레치하는 't', 하지만 페이지 중간에 迈向 재연됩니다 div 한다.
포지션: 절대 '다음' 위: 50 %50% '는' 와 '왼쪽 상단 모서리 선수단 가운데: 스크린, 왼쪽 가장자리 emc. 수직 수평으로 가운데 관심용 추가하기만' 여백 가기 '좋지 않게 보는 것, 즉, - 100 의 100 위에 높이의 div 와 마찬가지로 "에 대한 왼쪽 여백에'. Div '정확히' 이 페이지의 가운데에 가져옵니다.
<! - begin 스니핏: js 숨기십시오: 거짓값 콘솔: 진정한 바벨. > 거짓값 -;
#outPopUp {
position: absolute;
width: 300px;
height: 200px;
z-index: 15;
top: 50%;
left: 50%;
margin: -100px 0 0 -150px;
background: red;
}
<div id="outPopUp"></div>
끝 - < 스니핏 >;!
현대 [ 플렉상자 ] (http://caniuse.com/ # 검색 = 플렉상자) 솔루션은 길을 갈 입력 / 2015년). ['맞춤 컨텐트: 센터 '] (https://css-tricks.com/almanac/properties/j/justify-content/) 이 사용되는 모피쳐 요소점 정렬하려면 내용을 center of it.
<div class="container">
<div class="center">Center</div>
</div>
.container {
display: flex;
justify-content: center;
}
.center {
width: 800px;
}
<! - begin 스니핏: js 숨기십시오: 참 - >.
.container {
display: flex;
justify-content: center;
}
.center {
width: 800px;
background: #5F85DB;
color: #fff;
font-weight: bold;
font-family: Tahoma;
}
<div class="container">
<div class="center">Centered div with left aligned text.</div>
</div>
끝 - < 스니핏 >;!
Do you mean it 보기할 센터뿐만 가로 또는 세로로? '높이' 로 지정한 횡격막탈장의 /800mhz 픽셀입니다 않을 때 보다 큰 폭 '는', 그리고 그들이성년에 div 스트레치하기 iqn.
가로 가운데 사용할 수 있습니다 '로 승리를 거두었다. 자동차, '속성에 CSS. 또한, ll %s/dbase/ext_table. you& # 39 있는지 확인하기 위해 html 요소 '와' 없다 ',' 바디입니다 don& # 39 모든 이익 또는 패딩:
html, body { margin: 0; padding: 0; }
#centeredDiv { margin-right: auto; margin-left: auto; width: 800px; }
Div 안에 내용을 수정하지 않고 상위입니다 중심으로 가로 및 세로 크기 *
Here 이 페이지의 * 은 몇 가지 솔루션을 함께 공유할 수 있지만, 너무 좋은 개요에서는 fs@snapa 임무야, 어떤 코드를 사용할 수 있습니다.
Netwin * 개인적으로 맘에 들어 있는 것이 가장 유명한 변형 변환하기에 - 50%. 모두 잘 작동하잖아 고정 (%) 또는 px) 및 정의되지 않은 높이와 너비가 너회의 element.< br>; 이 코드는 같은 단순한:
HTML:
<div class="center"><div>
CSS.
.center {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%); /* for IE 9 */
-webkit-transform: translate(-50%, -50%); /* for Safari */
/* optional size in px or %: */
width: 100px;
height: 100px;
}
List. CSS flex 속성:
body { /* Centered */
display: box;
flex-align: center;
flex-pack: center;
}
코드 페이지 L& 중심으로 기존 셋업을 할 수 있는 다른 이전 div, R 다음과 같습니다.
지정하지 않고 중심으로 div 너버:
body {
text-align: center;
}
body * {
text-align: initial;
}
body div {
display: inline-block;
}
이 같은 ',' 태그번호 크기:, 그러나, center> < 뭔가 특별한 게 있다.
일부 경우 일반 텍스트 컨텐트나 뿐만이 아니라, 한 줄로 알고 있는 유일한 것이 가능한 이유는 계산하십시오 여백.
예를 들어보겠습니다.
<div id="supercontainer">
<div id="middlecontainer">
<div class="common" id="first">first</div>
<div id="container">
<div class="common" id="second">second</div>
<div class="common" id="third">third</div>
</div>
</div>
</div>
body {
margin: 0;
padding: 0;
}
.common {
border: 1px solid black;
}
#supercontainer {
width: 1200px;
background: aqua;
float: left;
}
#middlecontainer {
float: left;
width: 104px;
margin: 0 549px;
}
#container {
float: left;
}
#first {
background: red;
height: 102px;
width: 50px;
float: left;
}
#second {
background: green;
height: 50px;
width: 50px;
}
#third {
background: yellow;
height: 50px;
width: 50px;
}
그래서, '#', '와', '는 자신의 슈퍼콘타이너 " 전체 page" 너버' 는 '1200px'.
'#' 는 ',' 사이트의 내용이 있는 div 미들콘타이너 # 39 ',' s 'it& 너버 102px'. '콘텐츠' 의 경우 너버 page& # 39 의 크기를 알 수 있다 할 것, 's' 에서 # 39 의 2gb/s, subtract 반단면 content& 너버 결과:. 1200년 / 2 - (102 / 2) = 549.
예, 보고, 또한 이것이 I& # 39 m 페일오버합니다 der 그로 CSS.
'' 와 'a' '를 사용하여 맞춤 컨텐트 항목에서와 맞추십시오. 가로와 세로로 div 맞추십시오.'
https://developer.mozilla.org/de/docs/Web/CSS/justify-content https://developer.mozilla.org/en/docs/Web/CSS/align-items
<! - begin 스니핏: js 숨기십시오: 거짓값 콘솔: 진정한 바벨. > 거짓값 -;
html,
body,
.container {
height: 100%;
width: 100%;
}
.container {
display: flex;
align-items: center;
justify-content: center;
}
.mydiv {
width: 80px;
}
<div class="container">
<div class="mydiv">h & v aligned</div>
</div>
끝 - < 스니핏 >;!
body, html {
display: table;
height: 100%;
width: 100%;
}
.container {
display: table-cell;
vertical-align: middle;
}
.container .box {
width: 100px;
height: 100px;
background: red;
margin: 0 auto;
}
" ", 100%, 가로: " 대한 body"; 예를 들어 태그번호 사용됩니다. 실제 환경에서 이 재산이잖아 프로젝트 제거할 수 있습니다
아래 코드는 div 중심으로 한 상자:
<! - begin 스니핏: js 숨기십시오: 거짓값 콘솔: 진정한 바벨. > 거짓값 -;
.box-content{
margin: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
position: absolute;
width: 800px;
height: 100px;
background-color: green;
}
<div class="box-content">
</div>
끝 - < 스니핏 >;!