Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > margin: auto - but only up to a point

Reply
Thread Tools

margin: auto - but only up to a point

 
 
Tim Streater
Guest
Posts: n/a
 
      11-15-2007
I have an element that I would like to be centred on the page, so I use:

margin-left: auto;
margin-right: auto;

This is fine but under some conditions the element then expands to fill
the whole width of the window (variable content).

I would like to restrict its expansion to within (say) a few pixels of
the sides of the window. Can I do this with CSS?

Thanks,
 
Reply With Quote
 
 
 
 
Jonathan N. Little
Guest
Posts: n/a
 
      11-15-2007
Tim Streater wrote:
> I have an element that I would like to be centred on the page, so I use:
>
> margin-left: auto;
> margin-right: auto;
>
> This is fine but under some conditions the element then expands to fill
> the whole width of the window (variable content).
>
> I would like to restrict its expansion to within (say) a few pixels of
> the sides of the window. Can I do this with CSS?


width: 99%;

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
 
 
 
Tim Streater
Guest
Posts: n/a
 
      11-15-2007
In article <a9ed4$473c781e$40cba7a7$(E-Mail Removed)>,
"Jonathan N. Little" <(E-Mail Removed)> wrote:

> Tim Streater wrote:
> > I have an element that I would like to be centred on the page, so I use:
> >
> > margin-left: auto;
> > margin-right: auto;
> >
> > This is fine but under some conditions the element then expands to fill
> > the whole width of the window (variable content).
> >
> > I would like to restrict its expansion to within (say) a few pixels of
> > the sides of the window. Can I do this with CSS?

>
> width: 99%;


This appears to *force* the element (a table) to occupy 99% of the
width. I want to *limit* it to that.

I have:

table.outerbox
{
margin-left: auto;
margin-right: auto;
margin-top: 20px;
border-width: 4px;
border-color: black;
border-style: solid;
}


and then:

<table class="outerbox">
rows, cols
</table>

Thx - tim
 
Reply With Quote
 
Els
Guest
Posts: n/a
 
      11-15-2007
Tim Streater wrote:

> In article <a9ed4$473c781e$40cba7a7$(E-Mail Removed)>,
> "Jonathan N. Little" <(E-Mail Removed)> wrote:
>
>> Tim Streater wrote:
>>> I have an element that I would like to be centred on the page, so I use:
>>>
>>> margin-left: auto;
>>> margin-right: auto;
>>>
>>> This is fine but under some conditions the element then expands to fill
>>> the whole width of the window (variable content).
>>>
>>> I would like to restrict its expansion to within (say) a few pixels of
>>> the sides of the window. Can I do this with CSS?

>>
>> width: 99%;

>
> This appears to *force* the element (a table) to occupy 99% of the
> width. I want to *limit* it to that.


max-width:99%;

(does not work in IE6)

> I have:
>
> table.outerbox
> {
> margin-left: auto;
> margin-right: auto;
> margin-top: 20px;
> border-width: 4px;
> border-color: black;
> border-style: solid;
> }
>
> and then:
>
> <table class="outerbox">
> rows, cols
> </table>


You could always wrap it inside a div, and give the div a left and
right padding.


--
Els http://locusmeus.com/
 
Reply With Quote
 
Tim Streater
Guest
Posts: n/a
 
      11-15-2007
In article <967o70kru1lu.r0wadg43noa4$(E-Mail Removed)>,
Els <(E-Mail Removed)> wrote:

> Tim Streater wrote:
>
> > In article <a9ed4$473c781e$40cba7a7$(E-Mail Removed)>,
> > "Jonathan N. Little" <(E-Mail Removed)> wrote:
> >
> >> Tim Streater wrote:
> >>> I have an element that I would like to be centred on the page, so I use:
> >>>
> >>> margin-left: auto;
> >>> margin-right: auto;
> >>>
> >>> This is fine but under some conditions the element then expands to fill
> >>> the whole width of the window (variable content).
> >>>
> >>> I would like to restrict its expansion to within (say) a few pixels of
> >>> the sides of the window. Can I do this with CSS?
> >>
> >> width: 99%;

> >
> > This appears to *force* the element (a table) to occupy 99% of the
> > width. I want to *limit* it to that.

>
> max-width:99%;
>
> (does not work in IE6)


Didn't work in Safari 3, FF Mac/Win either
>
> > I have:
> >
> > table.outerbox
> > {
> > margin-left: auto;
> > margin-right: auto;
> > margin-top: 20px;
> > border-width: 4px;
> > border-color: black;
> > border-style: solid;
> > }
> >
> > and then:
> >
> > <table class="outerbox">
> > rows, cols
> > </table>

>
> You could always wrap it inside a div, and give the div a left and
> right padding.


Bit of a hack, but this *did* work. Thanks.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Shipping Auto Shipping Scheduling:car moving auto transport linkswanted ASP .Net 1 11-22-2013 07:02 AM
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
Scenario 5: IS-IS routing on Frame Relay Multi-point and Point-to-Point David Sudjiman Cisco 0 06-08-2006 09:11 AM



Advertisments