I am trying to get a div to float over a table so it will be on top of all the text?
Using div is better than using table because of easy control of the in the design and it can be container for controls than table and the table is mainlt used to group data with simillar structure so it's design is for this task but div is considered as container mainly than table.
Yes you can put table tag inside div tag . It's 100% valid.
The float property creates a floating box. The floating table can be created by applying this property to the TABLE element.
Check out absolute positioning, and possibly z-index as well (although if this is your only absolutely-positioned content, you won't need it). Although there are other ways to get things to overlap, that's probably the most relevant for you.
Very simple example:
CSS:
#target {
position: absolute;
left: 50px;
top: 100px;
border: 2px solid black;
background-color: #ddd;
}
HTML:
<p>Something before the table</p>
<div id="target">I'm on top of the table</div>
<table>
<tbody>
<tr>
<td>Text in the table</td>
<td>Text in the table</td>
</tr>
<tr>
<td>Text in the table</td>
<td>Text in the table</td>
</tr>
<tr>
<td>Text in the table</td>
<td>Text in the table</td>
</tr>
<tr>
<td>Text in the table</td>
<td>Text in the table</td>
</tr>
</tbody>
</table>
Live copy | source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With