Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DIV Space 1

Status
Not open for further replies.

AnakinPt

Programmer
Mar 29, 2001
583
PT
Hi.

I have a web site that i'm working on and it is made using tables.

I need to place an image inside of the table and i'm using a DIV tag with relative positioning.

The problem is that the DIV tag has a blank space that I can't remove placing too much space between tables.

You can see the website in [URL unfurl="true"]http://testes.securus.pt[/url]

See the mouse icon and the space between 2nd and 3rd tables in the left.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin@anikin-skywalker.com
 
This doesn't work.

I tried this piece of code but appears the blank space (1st table in the right column).

Code:
<div id="layerIconLoja" style="position:relative; left:152px; top:47px; z-index:1; display:visible; margin:0"><img src="/images/simbolocarrinho.gif"></div>

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin@anikin-skywalker.com
 
Call me crazy, but I don't see anything wrong.

What broswer are you coding this in??

I'm in FF 1.5.0.9 and IE6.

<.

 
Firefox, FF with IE tab and IE7.

None works.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin@anikin-skywalker.com
 
I don't understand. If you want the icon to appear a little higher, just make it's top a little lower value. Or is that number something special and should be exactly what it is right now. I didn't see that it would relate to anything important.

On the other hand, visible is not a valid value for display property.
 
If you go to the address i provided before, you can see what i need.

The div exists to place the shopping cart icon inside the table.


Anikin
Hugo Alexandre Dias
Web-Programmer
 
I guess I thought your problem was something else.

Ok, you're dealing with replaced content, which is not the best way of keeping everything flowing. Replaced content (using top, bottom, left, right with relative positioning) takes the element off its original position and puts it in the position specified (via top, bottom, left, right) while leaving its exact size as a gap in its original position. For you that means. Between your tables you have the div (or span, makes no difference) with the picture inside. If you look closely, the gap between the tables is that of the size of the image. Because div (or span) will be the size of the image inside and even though you then move it to another place, its original spot remains a gap. You can try and put a bigger picture in and you will see the gap growing bigger. Likewise with a smaller picture.

I don't think you're using an ideal approach (apart from non-ideally using tables for these lists when (well, well) lists (unordered or definition) would work much better. I would do it like this:
Code:
<table>
 <tr>
  <td><div style="position: relative;"><img style="position: absolute; right: 0; top: 0;"></div></td>
 </tr>
</table>
The div will create position boundaries in the first row of the table (which should be <th> instead of <td> but we will neglect this for the moment). Image will then be placed absolutely (not affecting the flow) in the top, right corner of this div that spans the entire table cell. Your image will be where you want it. Then you would move all this CSS in a separate stylesheet (use classes and dependant selectors) and you're done.
 
Thank you for your help. It was a gratefull hint.

Anikin
Hugo Alexandre Dias
Web-Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top