现在的位置: 首页 > 综合 > 正文

包含时如何给div定位

2018年01月27日 ⁄ 综合 ⁄ 共 774字 ⁄ 字号 评论关闭
用div的绝对定位:
<td style="position:relative">
<div style="position:absolute;left:0;top:0"></div>
</td>

不过要注意:这里的left和top是相对于table这个表格的左边距和顶边距而言的,因此如果table中有多行tr里面都包含了div,
那么就要精确计算table的每一行的高度了,例如:
<table width="100%" border="0" >
<tr>
<td style="height:28px; ">
<table width="100%">
<tr>
<td align="center" width="90%">
<font style="font-size:12px; font-family:宋体; color:black; ">创建主题</font>
</td>
<td align="right">
<a href="javascript:closeTopicCreate();" style="font-size:12px; color:black;">关闭</a>
</td>
</tr>
</table>
</td>
</tr>

<tr>
<td height="315px" >
<div style="position:absolute; left:0; top:30; height:320; width:498px; background:white; overflow:auto; ">


</div>
</td>
</tr>

<tr>
<td align="center" style="height:25px; " >
<input type="button" value="确定" onclick="javascript: createTopic();" style="height:20px;">
</td>
</tr>
</table>

抱歉!评论已关闭.