#1
  1. life isn't we think of it
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2003
    Location
    Kiev
    Posts
    2,027
    Rep Power
    55

    Question centering css object


    please anybody tell me how to put css object exactly in the center of the creen without HTML tables? is it possible?

    <style type="text/css">
    <!--
    .hdr{
    border: 1px solid #000;
    height: 120px;
    width: 700px
    }
    -->
    </style>

    TNX!
    Last edited by romalong; September 29th, 2003 at 05:07 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Rhondda Cynon Taff, Wales
    Posts
    172
    Rep Power
    11
    tyr adding this, but i am no css guru:

    PHP Code:
    aligncenter
    Ryan Jones (RyanJ)
  4. #3
  5. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1100
    Code:
    body
      {
      text-align: center; /* IE fix, see below */
      }
    .hdr
      {
      border: 1px solid #000;
      height: 120px;
      width: 700px;
      margin-left: auto;
      margin-right: auto;
      }
    What you're looking for is margin auto. This will center a block element. However, IE doesn't understand this, so it may be necessary to text-align: center; the body. Note that this is not proper CSS b/c text-align: is not suppose to effect block elements, only text/inline elements.

    There is another solution as well:
    Code:
    .hdr
      {
      position: relative;
      left: 50%;
      margin-left: -350px;
      }
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.
  6. #4
  7. life isn't we think of it
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2003
    Location
    Kiev
    Posts
    2,027
    Rep Power
    55
    oh, greate! thank u!
    all i have to do is just compose some graphic,text and borders without common html tables in order increasing load speed.

IMN logo majestic logo threadwatch logo seochat tools logo