Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make a div inside a td cell overlap the next td

Tags:

html

css

enter image description here

I want to be able to position the div (element E) inside the TD cell (element C) without the other TD cell (element D) getting pushed to the right.

Note: I can't edit anything on that page except for element E.

like image 330
Bogdan Avatar asked Sep 20 '11 15:09

Bogdan


2 Answers

Since you cannot edit any other element except for element E itself:

Move element E to a container:

<div style="position:relative;">
   <div id="element-E" style="position:absolute;"> ... </div>
</div>

I've added style attributes to the elements, because you alleged to not be able to modify other elements (such as <style>).

position:relative is required to correctly absolutely position a child element.

position:absolute; "tears" the element from its parent, and places it back again, relative to the upper-left corner of the parent (by default, when the position hasn't changed using top for example).

like image 43
Rob W Avatar answered Nov 30 '22 16:11

Rob W


Negative right margin ought to do the trick: margin-right: -50px;.

example: http://jsfiddle.net/peteorpeter/dvr9Z/

Absolute position could work, but adds other complications. Tables + absolute position can be painful, especially with fluid content.

like image 170
peteorpeter Avatar answered Nov 30 '22 16:11

peteorpeter