위치를 잘 잡으려면 (배경 이미지를 사용하지 않으려는 경우) DIV와 같은 블록 수준 요소로 내용을 래핑해야합니다. 표 셀의 하위 요소에는 position: absolute;
을 사용할 수 없습니다.
그래서,이 같은 것을 권장합니다
이
HTML :
<table cellpadding="0" cellspacing="0">
<thead>
<th>
<div class="positioning">
Left
<div class="img"> </div>
</div>
</th>
<th>
<div class="positioning">
Center
<div class="img"> </div>
</div>
</th>
<th>
<div class="positioning">
Right
<div class="img"> </div>
</div>
</th>
</thead>
<tbody>
<td>Left</td>
<td>Center</td>
<td>Right</td>
</tbody>
</table>
이 <div class="img"> </div>
단지 12 픽셀 X 12 픽셀 이미지입니다 상상해보십시오. (: padding: 10px 32px;
예)
CSS
table {
border: 10px solid rgb(230,230,230);
color: white;
}
table thead th,
table tbody td {
background: black;
border: solid 1px white;
font: bold 12px Helvetica, Arial, sans-serif;
padding: 10px;
}
table thead th {
padding: 0;
text-align: center;
}
table thead .positioning {
padding: 10px 32px;
position: relative;
}
table thead .img {
background: red;
height: 12px;
margin-top: -6px;
position: absolute;
right: 10px;
top: 50%;
width: 12px;
}
여기서 기억해야 할 중요한 것은 이미지를위한 공간을 만들기 위해 왼쪽과 positioning
DIV 충분한 패딩의 우측을 줄 것입니다. 그렇지 않으면 이미지가 텍스트 위에 겹쳐집니다.
는 여기에 바이올린입니다 : http://jsfiddle.net/brandondurham/nXQeR/
'' –