프로그램/html,css2014. 4. 19. 16:43

<html>
<head>
<style>
.middle_area {clear:both;position:relative;height:100%;}
.loading {position: absolute;top:50%;left:50%;}
</style>
</head>
<body>
 <div>상단 영역</div>
 <div class="middle_area">
  <div class="loading">세로 및 가운데 정중앙 정렬</div>
  <div>
   본문 영역<br />
   <a href="okkks.tistory.com" target="_blank">okkks.tistory.com</a><br />
   <a href="okkks.tistory.com" target="_blank">okkks.tistory.com</a><br />
   <a href="okkks.tistory.com" target="_blank">okkks.tistory.com</a><br />
   <a href="okkks.tistory.com" target="_blank">okkks.tistory.com</a><br />
   <a href="okkks.tistory.com" target="_blank">okkks.tistory.com</a><br />
   <a href="okkks.tistory.com" target="_blank">okkks.tistory.com</a><br />
   <a href="okkks.tistory.com" target="_blank">okkks.tistory.com</a><br />
   <a href="okkks.tistory.com" target="_blank">okkks.tistory.com</a><br />
   <a href="okkks.tistory.com" target="_blank">okkks.tistory.com</a>
  </div>
 </div>
 <div>하단 영역</div>
</body>
</html>

 

<div class="loading">세로 가운데 정중앙 정렬</div>를 본문 영역 기준으로 정중앙 정렬한 후 띄운다.

 

.middle_area {clear:both;position:relative;}

height:100%;부분을 삭제했을 경우


 

 

더보기>

- css div 글자 가로, 세로 가운데(중앙)정렬

Posted by 은둔고수
프로그램/html,css2013. 12. 7. 00:02

 

div를 이용해서 정사각형을 만들고 div 안에 텍스트를 가로, 세로 가운데(중앙) 정렬하는 한 예이다.

 

설명>

정사각형을 먼저 만들고

가로 정렬을 위해서 text-align:center를 사용하고

세로 정렬을 위해서 top:25%로 지정해서 세로 정렬을 한다.

가로 정렬은 크기가 변경이 되어도 가운데 정렬이 되나

세로 정렬은 크기가 변경되면 크기에 맞춰 top 값을 변경해서 맞춘다.

 

소스 예>

<html>
 <head>
  <title>div 정사각형안에 글자 가운데 정렬</title>
  <style>
  .type1 {height: 35px; width: 35px;border:1px solid;}
  .type2 {top: 25%; position: relative; text-align: center;}
  </style>
 </head>
<body>
<div class='type1'><div class='type2'>1</div></div>
</body>
</html>

 


더보기>

- css div 세로 가운데 정중앙 정렬해서 위로 띄우기

Posted by 은둔고수