/    Sign up×
Community /Pin to ProfileBookmark

extra space in table cell(s)

I define a simple table and put an image in each cell using js via:

[CODE][I]cellObject[/I].innerHTML=”<img src='”+imageArray[index]+”.jpg’>”[/CODE]

and in my style sheet I have

[CODE]img {width:150px; height:150px;}[/CODE]

and everything works fine: each cell is 150px square.

But then I add a script at the end of the document with:

[CODE][I]cellObject[/I].innerHTML=[I]cellObject[/I].innerHTML +

“<span id=’spanId’>text</span>”[/CODE]

and in my style sheet I have

[CODE]#spanId {position:relative; z-index=100; left:-94px; bottom:25px; margin:0; padding:0;color:gray;}[/CODE]

And this DOES succeed in superimposing the text within the span on top of the image.

BUT it also results in the cell (and hence the cell’s entire column of the table) becoming WIDER by what appears to be about 25%.

The added span tag is the cause of this widening, because when I comment out the js line adding it to the cell, the column with the cell returns to its prescribed width.

Any idea WHY the space is added? (It’s added on the right; if I add the span BEFORE the image the space is added on the left, even though in both cases the text itself is well within the image and the span element should be in a different plane/layer from the image.

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@JickNov 24.2008 — Have you tried [I]position:absolute[/I] on #spanId rather than [I]position:relative[/I]? One thing I'm sure that will happen is any positioning you apply when you have it set to [I]position:absolute[/I] will result in the text being outside it's container. You could remedy this by using padding and line-height instead. Or I think if you set the position of it's container as well it might look right. Can't remember exactly. Just know I've had some headaches over similar issues in the past.

Oh, by the way... The reason I'm suggesting [I]position:absolute[/I] rather than [I]position:relative[/I] is because [I]position:relative[/I] only repositions the object from where it is at normally and leaves a space where it was, whereas [I]position:absolute[/I] takes it out of the flow so you don't still have a space where it was. I think this might be your issue.
×

Success!

Help @jackacohen spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...