can you centre a DIV item in the window?

Discussion in 'HTML' started by Andy:P, Jan 8, 2004.

  1. Andy:P

    Andy:P Guest

    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
     
    Andy:P, Jan 8, 2004
    #1
    1. Advertising

  2. Andy:p wrote:

    > 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;
    }

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
     
    Toby A Inkster, Jan 8, 2004
    #2
    1. Advertising

  3. Andy:P

    Andy:P Guest

    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

    >
    > div#area {
    > width: 75%;
    > margin-left: auto;
    > margin-right: auto;
    > }
     
    Andy:P, Jan 9, 2004
    #3
  4. Toby A Inkster, Jan 10, 2004
    #4
  5. Andy:P

    Andy Peat Guest

    Andy Peat, Jan 11, 2004
    #5
  6. Andy:P

    Andy Peat Guest

    Andy Peat <> wrote:

    > Thanks Toby,
    > I will take a look at this tomorrow and see what happens.
    >
    > andy:p
    >
    > Toby A Inkster <> wrote:
    >
    > > http://www.goddamn.co.uk/tobyink/scratch/centre



    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
     
    Andy Peat, Jan 14, 2004
    #6
  7. In article Andy Peat wrote:
    > Andy Peat <> wrote:
    >
    > 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.

    --
    Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
    Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
    tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.
     
    Lauri Raittila, Jan 14, 2004
    #7
  8. Andy:P

    rf Guest

    "Andy Peat" <> wrote in message
    news:1g7kco2.1ttnmlw16rzz5oN%...
    > Andy Peat <> wrote:
    >
    > > Thanks Toby,
    > > I will take a look at this tomorrow and see what happens.
    > >
    > > andy:p
    > >
    > > Toby A Inkster <> wrote:
    > >
    > > > http://www.goddamn.co.uk/tobyink/scratch/centre

    >
    >
    > 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.
     
    rf, Jan 14, 2004
    #8
  9. Andy:P

    Andy Peat Guest

    Lauri Raittila <> wrote:
    > > Am I right that IE6 doesn't support external style sheets very well?

    >
    > 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
     
    Andy Peat, Jan 15, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chris

    DIV relative to centre ?

    chris, Aug 25, 2004, in forum: HTML
    Replies:
    6
    Views:
    9,674
    Daniel
    Sep 7, 2004
  2. Ant
    Replies:
    7
    Views:
    480
  3. xxfiredragonxx
    Replies:
    0
    Views:
    639
    xxfiredragonxx
    Dec 19, 2005
  4. Vince Morgan

    Centre an image in a <div>

    Vince Morgan, Nov 16, 2006, in forum: HTML
    Replies:
    10
    Views:
    923
    Vince Morgan
    Nov 16, 2006
  5. Spikey Mikey

    Centre table plus layers in window

    Spikey Mikey, Aug 5, 2004, in forum: Javascript
    Replies:
    0
    Views:
    87
    Spikey Mikey
    Aug 5, 2004
Loading...

Share This Page