gpt4 book ai didi

css align div right with at table at 100% on right

转载 作者:太空宇宙 更新时间:2023-11-04 04:58:18 27 4
gpt4 key购买 nike

我将表格设置为 100% 宽度。我会添加一个带有 php 的随机 div,有时会充满广告。我希望广告 div 位于表格的右侧和内容。我希望表格位于左侧,但仍为 100% 左右,它将填充广告 div 左侧的所有空间。

简而言之,当 div 不存在时,表格将填充 100% 宽度。当 div 存在时,div 将位于表格的右侧,宽度设置为 300px。

这是div的样式

.ContentAds {
float: right;
height: 100%;
width: 300px;
display: block;
clear: none;
}

表格不是 div,只是设置为 100% 宽度。

<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><p class="Title">Title</p>
<p>This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content. This is the content.. </p></td>
</tr>
</table>

最佳答案

目前我只能建议用定位的 div 包裹您的表格。但我不能确定这对你是否足够,因为你提供了相当少量的代码 jsfiddle

<div class="ad">
advertise... advertise
advertise... advertise
advertise... advertise
</div>
<div class="table_wr">
<table>
<tr>
<td>
<p class="Title">Title</p>
<p>
This is the content. This is the content.
This is the content. This is the content.
This is the content. This is the content.
This is the content. This is the content..
</p>
</td>
</tr>
</table>
</div>

CSS

body {
position: relative;
}
table {
border: 1px solid black;
width: 100%;
}
.ad {
float:right;
width:300px;
height: 500px;
background-color: #a2e89f;
}
.table_wr {
position: absolute;
left: 0;
right: 300px;
}

为表格设置了边框,以便您可以看到表格延伸的位置

关于css align div right with at table at 100% on right,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11995421/

27 4 0