CSS positioning of images
Does anyone know how I can change the position of an image element using a style sheet? I have a division which contains only the image. I have given the division an ID image a CLASS:
In my style sheet I have the following statements:
#logo {border: thin solid white; background: white; }
img.menu {border: thick red solid; }
The background behind my image is white and the image has a red border round it, so I'm doing something right!
What I want to do is center the image within the division. I have tried the following style sheet :
#logo {border: thin solid white; background: white; align: center; }
img.menu {border: thick red solid; align: center; }
but the image remains stubbonly on the left!
I have other classes of images positioned on the left and right using the float property but I can't find anything in the CSS specification to allow central images. All I can think of it resorting to
which works but is very very ugly and I'd like to know how to do it properly.
Hope someone can help me!
Robin
Robin Hall (Miss)
The Webmistress posted this at 15:03 — 18th December 2001.
She has: 5,586 posts
Joined: Feb 2001
Hiya Robin,
I don't know the answer to this as I'm just getting to grips with css myself but just wanted to say welcome to TWF, fellow 'near Portsmouth person'. Stop by the Introductions forum and introduce yourself
Julia - if life was meant to be easy Michael Angelo would have painted the floor....
Suzanne posted this at 22:15 — 18th December 2001.
She has: 5,507 posts
Joined: Feb 2000
centering things with CSS remains annoying. Setting margins to auto works for some things, not for others, and not in the main browser (ie).
If possible, try using positioning instead (top, left, right, bottom).
S
elanbob posted this at 10:07 — 19th December 2001.
They have: 7 posts
Joined: Dec 2001
The containing division is sized using a relative unit.
Can you think of any way of positioning my image using relative units? I am not setting the absolute size of the containing division and I want to image to look centered on all screen resolutions/sizes/platforms ...
Jack Michaelson posted this at 11:57 — 19th December 2001.
He has: 1,733 posts
Joined: Dec 1999
Maybe place a table in the and place the in a . Then you could do some positioning in the 's class...
Hope it helps
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.