CSS problem

by 4 replies
5
Hey warriors,
In my website - http://beta.jokesnfunnypics.com/test , when I zoom in or out, it zooms in and out from the top left whereas in almost every site - (take warriorforum.com), when I zoom in or out it zooms in or out from the center. Please tell me whats the problem. If have reduced the code for you to help me better. Please help me!
Thanks in advance
#programming #css #problem
  • I think you want margin: auto?
    • [ 1 ] Thanks
    • [1] reply
    • Centering CSS divs can be harder than it seems. Sometimes I still have a difficult time with it on complex designs. It is best to start with a centered design then add to it rather than try to retroactively center a complex design!

      At the most basic level, there are three factors are involved:
      width, margin, and text-align.

      - Center the body contents.
      - Create a div with width less than 100%.
      - Set div margins to auto.

      The following is the bare minimum CSS needed to center a div:


      body {
      text-align: center;
      }

      div.main{
      width: 80%;
      margin: auto;
      }
  • text-align:center is definately NOT for centering div's.

    It is to align TEXT. Go back to learn proper CSS.
    • [ 1 ] Thanks
  • if you set a div to a specific height you can use margin left , margin right auto, ie:

    width:800px; margin-left:auto; margin-right:auto;

Next Topics on Trending Feed

  • 5

    Hey warriors, In my website - http://beta.jokesnfunnypics.com/test , when I zoom in or out, it zooms in and out from the top left whereas in almost every site - (take warriorforum.com), when I zoom in or out it zooms in or out from the center. Please tell me whats the problem. If have reduced the code for you to help me better. Please help me! Thanks in advance