Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-04-18 18:53:00

daikw
Member
Registered: 2007-10-06
Posts: 39

CSS: centering whilst controlling column width

Hi there,

I am having some problems aligning the body content and navigation elements of my textpattern site.

I would like all content on the page to be center aligned, like this

However, I need to be able to control the column width of content so that I can limit the image thumbnails, to say, 9 thumbnails per line.

However, when I create a div for a block of content and style it using width: 960px; it suddenly loses its centered position. like this

Could someone tell me how I can keep all the elements centered, but still be able to control their width?

Last edited by daikw (2008-04-18 18:53:19)

Offline

#2 2008-04-18 19:05:50

bancroft
Member
Registered: 2005-09-30
Posts: 39

Re: CSS: centering whilst controlling column width

On #bodycopy change margin: 30px 0px; to margin: 30px auto; that will center the div.

Offline

#3 2008-04-18 22:01:24

daikw
Member
Registered: 2007-10-06
Posts: 39

Re: CSS: centering whilst controlling column width

Thanks a million, Bancroft, I will remember that one now! :D

Offline

#4 2008-04-20 23:57:35

daikw
Member
Registered: 2007-10-06
Posts: 39

Re: CSS: centering whilst controlling column width

Okay, that works for Firefox, but when I load a page in a windows version of IE, the content still moves to the left side of the page.

Could someone suggest a fix or a hack for IE?

Thanks

Offline

#5 2008-04-21 00:23:47

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: CSS: centering whilst controlling column width


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#6 2008-04-21 01:41:11

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: CSS: centering whilst controlling column width

Also, ya should little validate your page. Yes, it does almost pass the validators, but it’s just coz it can not be parsed as there is no document type nor html tags used correctly, and therefor the code is untraceable.

So, my todo would be in this case:

  • Add doctype
  • Add html starting tags
  • Remove the XHTML from the <head> – there shouldn’t be any non-head beloning data.
  • Then validate it

As it’s current state, it’s working, in some browsers, some not at all, coz there is some really big pitfalls. But it’s good start :)

Offline

#7 2008-04-21 02:04:23

masa
Member
From: Asturias, Spain
Registered: 2005-11-25
Posts: 1,091

Re: CSS: centering whilst controlling column width

Older IEs will sometimes expand your overall container as they see fit. Adding a property like overflow-x: hidden; will in most cases bring back things into alignment.

Offline

#8 2008-04-21 08:02:30

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: CSS: centering whilst controlling column width

Use the version of bancroft and be sure browsers render your site in standard compliance mode. So no hack for an IE is needed.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

Board footer

Powered by FluxBB