1

I would like to add a div inside to a td, and position/size out the div from the td (horizontally or vertically or both). My problem is, for example if I add a top margin to the div, the whole row of the table height is increasing to include the div.

Is there any way to leave the td's height and width intact and position/size the div outside the td? The div must remain the child element of the td.

The same question for 'a' element. I am not sure the answer is different than for the div, or the solution (if any) is the same for the div and 'a'.

Thanks in advance

g.pickardou
  • 32,346
  • 36
  • 123
  • 268
  • 2
    Please, show your code! Imagine going to a mechanic and telling him you have a problem with your car _without showing him your car_. How is he meant to help you? How are we? – Kyle May 06 '13 at 12:12
  • Try to put `position: absolute` on your `a`, `div` – Doan Cuong May 06 '13 at 12:13
  • 1
    Sounds like you don't want to use tables for layout to me. – Mark Schultheiss May 06 '13 at 12:20
  • Tested it [here](http://jsfiddle.net/fHT5z/) and the explanation found [here](http://stackoverflow.com/questions/290335/how-can-i-position-an-element-at-the-bottom-of-its-container-in-firefox/290395#290395) – Stano May 06 '13 at 13:04

2 Answers2

2

Give position: absolute to your child element. and also display: inline or display: inline-block if it is a block element like div (not necessary for a tag).

And then by using top and left, set the position of the child element. (give negative values)

Mr_Green
  • 40,727
  • 45
  • 159
  • 271
1

You can have:

position:absolute;

for you div

and then navigate outside like:

top:-10px and so on...

user123_456
  • 5,635
  • 26
  • 84
  • 140