|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
css and table alignment
curious, how to get a table to align in a horizontal manner using css...with html you would just
<table align="center"> but, i tried table {align: center;} to no avail, ive looked some things up and it appears that's not valid... any ideas aside from hard coding it into the html? |
|
#2
|
||||
|
||||
|
Code:
table
{
margin-left: auto;
margin-right: auto;
}
|
|
#3
|
|||
|
|||
|
just tried your solution, still defaulted to the left...
|
|
#4
|
|||
|
|||
|
|
|
#5
|
|||
|
|||
|
k, thanks -- will give it a try in a few
**hrm, that doesnt work either -- im not sure what's goin on but im not liking it...** Last edited by ROT : June 5th, 2003 at 10:54 AM. |
|
#6
|
|||
|
|||
|
maybe because that was for centering text and im trying to center a table
|
|
#7
|
||||
|
||||
|
actually, adios was right,
to center a table you need to contain it within a DIV which has text-align: center applied to it ... and bob's your fathers brother so: <style> div.centerinner { text-align: center; } </style> ... <div class="centerinner"> <table> <tr> <td> </td> <tr> </table> </div> should produce the effect you are after ... unless you're using some weird browser combination I'm not aware of! Icy |
|
#8
|
|||
|
|||
|
im an idiot, pft...
style code: div#content {text-align: center;} html code: <div id="content"> </div> had my text-align left instead of center ![]() showing myself again to check the basics first... **well, problem with this is it aligns any untagged text center also. so you either have to tag the text left or find a diff way** Last edited by ROT : June 5th, 2003 at 11:29 AM. |
|
#9
|
|||
|
|||
|
Just override the 'outer' alignment with specific CSS applied to the nested element(s) involved. No extra charge.
![]() |
|
#10
|
|||
|
|||
|
not sure what you just said
|
|
#11
|
|||
|
|||
|
Notice this...
.outerCenter { text-align: center; } .innerCenter { text-align: left; margin-left: auto; margin-right: auto; } ...from the example I posted? Because the left-aligning rule is more specific ('closer' to) any contained text, it over-rides the text-align rule in the outer container. Try it. |
|
#12
|
|||
|
|||
|
ah, i see what you're saying... ya, i already got it taken care of due to the fact the titlebar and content sections of the table were already id'd
|
|
#13
|
||||
|
||||
|
This is driving me nuts. I've seen how setting the left and right margins can be used to horizontally centre something. And IE6 correctly renders it when I view these pages that do it. But for some reason it doesn't work when I try it on my own pages. Here's my code...
Code:
<style type="text/css">
<!--
#content-area {
padding : 10px 20px 20px 20px;
}
#content-area div.diagram {
width : 50%;
border-top : 2px solid Black;
border-bottom : 2px solid Black;
padding-top : 10px;
margin : 0px auto;
}
div.diagram span.caption {
border-top : 1px solid Black;
display : block;
margin-top : 10px;
font-size : smaller;
width : 100%;
}
-->
</style>
</head>
<body>
<div id="content-area">
<div class="diagram">
<img src="images/image.gif" width="300" height="200" /><br />
<span class="caption"><strong>Figure 1:</strong> Lorem ipsum dolor sit amet,
consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet
dolore magna aliquam erat volutpat.</span>
</div>
</div>
</body>
This works in Opera but not in IE6 and I can't work out why. I know IE6 supports this use as this same method is used on http://www.alistapart.com/stories/practicalcss/ and it renders perfect. Any ideas what I'm doing wrong? Note: I have tried different ways of setting the left and right margins but it never make any difference. I also know an alternative method to centre it by giving diagram a pixel width and a negative sized margin but I really want a percentage width ![]()
__________________
Ooh, they have the Internet on computers now! |
|
#14
|
||||
|
||||
|
Code:
#content-area
{
padding : 10px 20px 20px 20px;
text-align: center; /* IE support */
}
|
|
#15
|
|||
|
|||
|
Yes, IE does not support the margin: auto; property correctly.
|
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > css and table alignment |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|