2009-11-09 5 views
1

오른쪽에있는 다른 텍스트 "sub"로 텍스트 "main"을 가운데 맞춤해야합니다. 둘 다 중심에두기를 원하지 않습니다. 오른쪽에 "sub"가있는 "main"센터. 그것은 IE6에서 작동 할 필요가 없습니다. 나는 그것을 작동 시키지만, 텍스트의 바닥은 오른쪽으로 정렬되지 않습니다. 나는 스타일 바닥을 적용했다 : .2em 그리고 그것이 효과가있다. 그러나 텍스트의 하단을 정렬하는보다 논리적 인 방법이 있는지 알고 싶습니다. 여기에서 바이올린 수 있습니다. link text가운데 오른쪽으로 밀어 넣기

업데이트 : "main"과 "sub"주변의 패딩을 제거하려면 어떻게해야합니까? 그게 도움이 될거야.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<style type="text/css"> 
*{padding:0;margin:0} 
.container{ 
border:thin solid yellow; 
text-align:center; 
} 
.main{ 
border:thin solid blue; 
display:inline; 
position:relative; 
font-size:4em; 
} 
.sub{ 
border:thin solid red; 
position:absolute; 
left:100%; 
font-size:.5em; 
bottom:.2em; 
} 
</style> 
</head> 
<body> 
<div class="container"> 
    <div class="main"> 
    Main 
    <div class="sub">&nbsp;(Sub)</div> 
    </div> 
</div> 
</body> 
</html> 

답변

0

3 명 div의

*{padding:0;margin:0} 
 
.container{ 
 
border:thin solid yellow; 
 
text-align:center; 
 
} 
 
.left{ 
 
float:left; 
 
} 
 
.main{ 
 
border:thin solid blue; 
 
display:inline; 
 
position:relative; 
 
font-size:4em; 
 
float:left; 
 
} 
 
.sub{ 
 
border:thin solid red; 
 
position:absolute; 
 
left:100%; 
 
font-size:.5em; 
 
bottom:.2em; 
 
float:left; 
 
}
<div class="container"> 
 
    <div style="float:left"> 
 
    </div> 
 
    <div class="main"> 
 
    Main 
 
    </div> 
 
    <div class="sub">&nbsp;(Sub)</div> 
 
</div>

플로트를 추가를 넣어 각 div의에 남아.

관련 문제