can you centre a DIV item in the window?

A

Andy:P

Dear all
I am trying to get to grips with the CSS styles and want to replicate
something that used to be done with tables.

I have a box with an image in (I've called this div id=area) that I
want to centre in the browser window.

I then want another box that will contain text to float over the first
box and move with the box when the window is resized.

It seems that with DIV you can only make an absolute or relative
position. (I may be wrong)

What is the best way of going about this?

thanks in advance.
andy:p
 
T

Toby A Inkster

Andy:P said:
I have a box with an image in (I've called this div id=area) that I
want to centre in the browser window.

div#area {
width: 75%;
margin-left: auto;
margin-right: auto;
}
 
A

Andy:P

Thank you for your answer.

I have put together a page template that I have been working on using
CSS but its not working in IE5 for Windows (it works on Opera6 and IE5
for mac).

Would you mind taking a quick look and giving me any pointers as to
why and what I could do?

The page can be found at:
<http://www.apeat.demon.co.uk/test/test.html>
The result I am trying to achieve is at:
<http://www.apeat.demon.co.uk/test/as_it_should_be.jpg>
The CSS external style sheet is at
<http://www.apeat.demon.co.uk/test/resources/test.css>

Thank you in advance.
andy:p
 
A

Andy Peat

Andy Peat said:
Thanks Toby,
I will take a look at this tomorrow and see what happens.

andy:p


Am I right that IE6 doesn't support external style sheets very well?

It seems as though the layout styles need to be in the same document -
is this right, can I not have them in an external sheet?

thanks.
andy:p
 
L

Lauri Raittila

In said:
Am I right that IE6 doesn't support external style sheets very well?

No you are not. It supports them well enaugh.
It seems as though the layout styles need to be in the same document -
is this right, can I not have them in an external sheet?

I think you are making some mistake, that is impossible to spot whitout
url.
 
R

rf

Andy Peat said:
Am I right that IE6 doesn't support external style sheets very well?

It seems as though the layout styles need to be in the same document -
is this right, can I not have them in an external sheet?

Do you perchance have
<style ...>
and
</style>
in your external CSS file?

If so, don't.

Cheers
Richard.
 
A

Andy Peat

Lauri Raittila said:
No you are not. It supports them well enaugh.

I am entirely wrong, sorry for not checking this properly - There was an
error in the code and it didn't appear to work.

Thanks.
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top