centering a div tag usind css

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default centering a div tag usind css

    i wish to centre a div tag on my page using css so that it remain in the centre of my page no matter how much i expand and retract my browser

    thanks
    ian2003 Guest

  2. Similar Questions and Discussions

    1. Centering Pages
      Is there any way I could make Pub 2003 automatically (or manually in a simple way), center the entire page contents under the nav bar? I added a...
    2. Centering
      In Publisher 2000, centering a title or headline between text that is full justified or left justified results in a bunch of extra space above and...
    3. Centering SWFs
      This may be a silly question, but I can't seem to figure it out. How does one center a swf file on an HTML page without using a table?
    4. usind mv in a script
      I know that you can find files and removed them after a certain number of days from creation date. Can you find files and move them to another...
    5. centering frames
      I have created a site with 3 frames - navigation at the top (changes both frames below), navigation at the left side (changes content in frame at...
  3. #2

    Default Re: centering a div tag usind css

    Using css, apply:

    body { text-align: center;) //this is for Internet Explorer

    for your container div

    #container {margin: 0 auto; position: relative; width: 790px;} //use any
    width you prefer

    This will center your container div horizontally in the broswer window

    Hope this helps.
    Regards,
    -D-


    "ian2003" <webforumsuser@macromedia.com> wrote in message
    news:dmn5vm$dpo$1@forums.macromedia.com...
    > i wish to centre a div tag on my page using css so that it remain in the
    centre of my page no matter how much i expand and retract my browser
    >
    > thanks


    -D- Guest

  4. #3

    Default Re: centering a div tag usind css

    Wouldn't need the position:relative to make it center.

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================


    "-D-" <someone@NOSPAM.com> wrote in message
    news:dmn72q$fer$1@forums.macromedia.com...
    > Using css, apply:
    >
    > body { text-align: center;) //this is for Internet Explorer
    >
    > for your container div
    >
    > #container {margin: 0 auto; position: relative; width: 790px;} //use any
    > width you prefer
    >
    > This will center your container div horizontally in the broswer window
    >
    > Hope this helps.
    > Regards,
    > -D-
    >
    >
    > "ian2003" <webforumsuser@macromedia.com> wrote in message
    > news:dmn5vm$dpo$1@forums.macromedia.com...
    >> i wish to centre a div tag on my page using css so that it remain in the
    > centre of my page no matter how much i expand and retract my browser
    >>
    >> thanks
    >
    >
    >

    Murray *TMM* Guest

  5. #4

    Default Re: centering a div tag usind css

    Yep, the relative positioning isn't mandatory. I use a relative positioned
    div so when I use absolute positioned divs within the container, they
    position correctly.

    "Murray *TMM*" <forums@HAHAgreat-web-sights.com> wrote in message
    news:dmndvm$q7n$1@forums.macromedia.com...
    > Wouldn't need the position:relative to make it center.
    >
    > --
    > Murray --- ICQ 71997575
    > Team Macromedia Volunteer for Dreamweaver
    > (If you *MUST* email me, don't LAUGH when you do so!)
    > ==================
    > [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    > [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    > [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    > [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    > ==================
    >
    >
    > "-D-" <someone@NOSPAM.com> wrote in message
    > news:dmn72q$fer$1@forums.macromedia.com...
    > > Using css, apply:
    > >
    > > body { text-align: center;) //this is for Internet Explorer
    > >
    > > for your container div
    > >
    > > #container {margin: 0 auto; position: relative; width: 790px;} //use
    any
    > > width you prefer
    > >
    > > This will center your container div horizontally in the broswer window
    > >
    > > Hope this helps.
    > > Regards,
    > > -D-
    > >
    > >
    > > "ian2003" <webforumsuser@macromedia.com> wrote in message
    > > news:dmn5vm$dpo$1@forums.macromedia.com...
    > >> i wish to centre a div tag on my page using css so that it remain in
    the
    > > centre of my page no matter how much i expand and retract my browser
    > >>
    > >> thanks
    > >
    > >
    > >
    >
    >


    -D- Guest

  6. #5

    Default Re: centering a div tag usind css

    I have a question on this too, so instead of starting a new topic, here goes.

    I want to define a class in an external CSS file so that I can use the same
    frame style all over my site. I want it to be 400 px wide and centered. I
    can't find any setting in the CSS to tell it to be centered. The only things
    for centering seem to center the text.

    Here is my class:
    .box400 {
    background-color: #F5F5F5;
    padding: 5px;
    height: auto;
    width: 400px;
    border: 2px dotted #660000;
    }

    When I do my div with that class it works. If I add align=center to the same
    div tag, it ignores the center command. I had to nest that div inside another
    to get the dang thing to center. That shouldn't be needed.

    I saw above where it said to define center in the body tag, but that won't
    work on my site, because everything is layed out from the left and it alread
    explicitly defines left in the body tag.

    Thanks,

    Kirk

    kirkdickinson Guest

  7. #6

    Default Re: centering a div tag usind css

    I have a question on this too, so instead of starting a new topic, here goes.

    I want to define a class in an external CSS file so that I can use the same
    frame style all over my site. I want it to be 400 px wide and centered. I
    can't find any setting in the CSS to tell it to be centered. The only things
    for centering seem to center the text.

    Here is my class:
    .box400 {
    background-color: #F5F5F5;
    padding: 5px;
    height: auto;
    width: 400px;
    border: 2px dotted #660000;
    }

    When I do my div with that class it works. If I add align=center to the same
    div tag, it ignores the center command. I had to nest that div inside another
    to get the dang thing to center. That shouldn't be needed.

    I saw above where it said to define center in the body tag, but that won't
    work on my site, because everything is layed out from the left and it alread
    explicitly defines left in the body tag.

    Thanks,

    Kirk

    kirkdickinson Guest

  8. #7

    Default Re: centering a div tag usind css

    You're looking to style a FRAME with CSS? Or did you mean <div>?
    > If I add align=center to the same
    > div tag, it ignores the center command.
    No it doesn't. It will center the inline content you put into it.
    > I had to nest that div inside another
    > to get the dang thing to center.
    So - you are trying to make the <div> tag itself center in its container?
    Then you would have to give that <div> a width and assign auto left and
    right margins. For example, this div will be centered -

    body { text-align:center; }
    #centeredDiv { width:300px;border:1px solid blue;margin:0 auto; }
    .....

    <body>
    <div id="centeredDiv">take a look</div>
    </body>
    > That shouldn't be needed.
    And it's not.
    > I saw above where it said to define center in the body tag, but that won't
    > work on my site, because everything is layed out from the left and it
    > alread
    > explicitly defines left in the body tag.
    That's OK. Go ahead and use the text-align:center.

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================


    "kirkdickinson" <webforumsuser@macromedia.com> wrote in message
    news:dnvgpo$28d$1@forums.macromedia.com...
    >I have a question on this too, so instead of starting a new topic, here
    >goes.
    >
    > I want to define a class in an external CSS file so that I can use the
    > same
    > frame style all over my site. I want it to be 400 px wide and centered.
    > I
    > can't find any setting in the CSS to tell it to be centered. The only
    > things
    > for centering seem to center the text.
    >
    > Here is my class:
    > .box400 {
    > background-color: #F5F5F5;
    > padding: 5px;
    > height: auto;
    > width: 400px;
    > border: 2px dotted #660000;
    > }
    >
    > When I do my div with that class it works. If I add align=center to the
    > same
    > div tag, it ignores the center command. I had to nest that div inside
    > another
    > to get the dang thing to center. That shouldn't be needed.
    >
    > I saw above where it said to define center in the body tag, but that won't
    > work on my site, because everything is layed out from the left and it
    > alread
    > explicitly defines left in the body tag.
    >
    > Thanks,
    >
    > Kirk
    >

    Murray *TMM* Guest

  9. #8

    Default Re: centering a div tag usind css

    > You're looking to style a FRAME with CSS? Or did you mean <div>?

    I wanted to use a Div to define a box.
    >No it doesn't. It will center the inline content you put into it.
    Yeah, it centers the content inside the div. I was trying to define the div
    itself to center. That is why I had to nest the div's.
    >So - you are trying to make the <div> tag itself center in its container?
    Yep.
    >Then you would have to give that <div> a width and assign auto left and
    >right margins. For example, this div will be centered -
    >
    >body { text-align:center; }
    >#centeredDiv { width:300px;border:1px solid blue;margin:0 auto; }
    >....
    >
    ><body>
    ><div id="centeredDiv">take a look</div>
    ></body>
    Yes, that works, but when I set body { text-align:center; } it causes other
    problems on the site.

    Thanks

    kirkdickinson Guest

  10. #9

    Default Re: centering a div tag usind css

    Leave the text-align:left in the body tag and it will all come out in the
    wash.

    --
    Murray --- ICQ 71997575
    Team Macromedia Volunteer for Dreamweaver
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    [url]http://www.dreamweavermx-templates.com[/url] - Template Triage!
    [url]http://www.projectseven.com/go[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.dwfaq.com[/url] - DW FAQs, Tutorials & Resources
    [url]http://www.macromedia.com/support/search/[/url] - Macromedia (MM) Technotes
    ==================


    "kirkdickinson" <webforumsuser@macromedia.com> wrote in message
    news:do04p7$qf4$1@forums.macromedia.com...
    >> You're looking to style a FRAME with CSS? Or did you mean <div>?
    >
    > I wanted to use a Div to define a box.
    >
    > >No it doesn't. It will center the inline content you put into it.
    >
    > Yeah, it centers the content inside the div. I was trying to define the
    > div
    > itself to center. That is why I had to nest the div's.
    >
    > >So - you are trying to make the <div> tag itself center in its container?
    >
    > Yep.
    >
    > >Then you would have to give that <div> a width and assign auto left and
    > >right margins. For example, this div will be centered -
    > >
    > >body { text-align:center; }
    > >#centeredDiv { width:300px;border:1px solid blue;margin:0 auto; }
    > >....
    > >
    > ><body>
    > ><div id="centeredDiv">take a look</div>
    > ></body>
    >
    > Yes, that works, but when I set body { text-align:center; } it causes
    > other
    > problems on the site.
    >
    > Thanks
    >

    Murray *TMM* Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139