CSS를 이용하여 이미지를 화면 중앙에 정렬하기.

강의자료/Web | 2011.03.10 18:26 Share |


파이어폭스, 크롬, 사파리, 익스플로러 모두 작동합니다.

CSS

#enter {
position: absolute;
text-align: center;
left: 50%;
top: 50%;
margin: -120px auto 0 -130px; /* value of top margin: height of the image divide by 2 (ie: 240 / 2), value of left margin: width of the image divide by 2 (ie: 260 / 2) */
width: 260px; /* same as the image width */
}

#enter span a {
display: block;
width: 260px;
height: 240px;
margin: 0 auto;
position: relative;
background: transparent url(images/enter.jpg) 0 0 no-repeat;
text-indent: -5000em;
outline: 0;
}

HTML

<body id="homepage">
    <div id="enter">
<span><a href="/home">Enter Site</a></span>
    </div>
</body>

.....This article is posted by whitesnake.
강의자료/Web | 2011.03.10 18:26

댓글을 달아 주세요

1 ··· 33 34 35 36 37 38 39 40 41 ··· 176