Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2009
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Centre-Align elements

    How do you make an element centre align. For example I have an image within a column and want it to centre within that column?

    cheers

  • #2
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Is this any use to you here.

    Some extra help here

    Frank
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,744
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Quote Originally Posted by GBizzle99 View Post
    I have an image within a column and want it to centre within that column?

    cheers
    To center anything you need 3 things:
    1. a DocType declaration
    2. an element with a width
    3. that elements left and right margins set to auto


    Since you kjnow the width of your image, give it an id... <img src="myDir/myPic.jpg alt="description" id="pic1" />
    and then style that id in your CSS.
    Like this -
    Code:
    #pic1 {
    width: XXpx;
    margin: 0 auto;
    }
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #4
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by effpeetee View Post
    Is this any use to you here.

    Some extra help here

    Frank
    The first link is quite handy, thanks a lot. Lots of great information out there, just a matter of finding it.


  •  

    Posting Permissions

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