|
-
Feb 28th, 2010, 03:50 PM
#1
Thread Starter
Hyperactive Member
how can i place something in a table?
i want to place in a table some buttons and aother things
i see that with the position absolute they dont go where i want
what can i do?
-
Feb 28th, 2010, 06:51 PM
#2
Re: how can i place something in a table?
You can post some code. I'm not sure what you're talking about - are you trying to add elements to a table with Javascript, or are you just having CSS positioning issues (or both)?
-
Feb 28th, 2010, 10:52 PM
#3
Fanatic Member
Re: how can i place something in a table?
don't use position, try to use margin as much as you can...
if i get what you're saying right then you should look at this:
Code:
<table>
<tr>
<td><input type="submit" name="somename" /></td>
</tr>
</table>
-
Mar 3rd, 2010, 09:28 AM
#4
Thread Starter
Hyperactive Member
Re: how can i place something in a table?
because i am not home i cannot paste code..
the problem is at the css positioning
i am not using javascript
the problem is that in a table i cannot place things where i want
with the absolute positioning i see things in my visual studio in a place and in the browser they appear somewhere else
how can i handle it?
-
Mar 3rd, 2010, 10:48 AM
#5
Re: how can i place something in a table?
you shouldn't really be using absolute position in the first place, anyway. it's sort of unnecessary in almost all cases. if you could show us your code (post from home?), I'm sure a lot of us could help you find a better, easier way of doing what you'd like to do.
however, if you insist on using absolute positioning, make sure that the parent of the elements that are positioned absolutely is positioned relative, so that child elements stay within the parent. for example, if you had the following mark-up:
HTML Code:
<table>
<tr>
<td>
<div class="myDiv</div>
</td>
</tr>
</table>
and applied this style sheet:
Code:
td {
width: 300px;
background: #f00;
}
.myDiv {
width: 100px;
height: 100px;
background: #ff0;
position: absolute;
top: 50%;
}
then the top of the div element myDiv will be positioned in the center of the page vertically. that's because the parent element (in this case td) is not positioned relative, and so the browser wants to render myDiv as positioned from the top of the page itself. this is probably not desirable, as in this case I would have wanted that element to be in the center of the td element vertically. so, you can modify the stylesheet:
Code:
td {
position: relative;
width: 300px;
background: #f00;
}
.myDiv {
width: 100px;
height: 100px;
background: #ff0;
position: absolute;
top: 50%;
}
this lets the browser know that you want to position myDiv from the relative position of the td element.
and one last thing: if you're using a WYSIWYG editor (like Dreamweaver, or Visual Studio, or whatever else), then I would suggest you never use the design view if you want to see how something looks. it's unreliable. I would suggest just typing out code yourself (if you aren't already).
-
Mar 3rd, 2010, 01:23 PM
#6
Thread Starter
Hyperactive Member
Re: how can i place something in a table?
thanks..
i will try it at friday when i will be home
in the fact i use visual studio and i use the design view..
i positioned the parent absolute and i tried to position the child relative or absolute
now with your suggest i will try to posinion the parent relative and the child absolute
lets see..
i will tell you on friday but i am sure that you will be right..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|