#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    66
    Rep Power
    3

    Centering an Image


    I am writing the home page for a website here is my code that I am using for a slideshow for this purpose I will just make up a name.


    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta name="keywords" "question"/>
    <style>
    
    div
    {
    width:10px
    height:10px
    box-shadow: 10px 10px 5px #888888 
    }
    
    </style>
    </head> 
    
    <body> 
    <div><img src="img.jpeg"/></div>


    My question is whenever I try to center img.jpeg it will not center i have tried

    <p align="center"><div><img src="img.jpeg"></div></p>

    I have tried

    <div align="center">img src="img.jpeg"></div>

    and

    <div><center><img src="img.jpeg"></div>

    but none of these work so how can I center this photo? thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Location
    Sydney Australia
    Posts
    189
    Rep Power
    84
    Originally Posted by Nick Wyden

    but none of these work so how can I center this photo? thanks
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta name="keywords" "question"/>
    <style>
    
    .pic
    {
    width:100px;
    height:100px;
    box-shadow: 10px 10px 5px #888888 ;
    
    }
    .center {
    	width:100px;
    	padding: none;
    	margin:0 auto;
    }
    </style>
    </head> 
    
    <body> 
    <div class="center"><img class='pic' src="img.jpeg"/></div> 
    </body>
    </html>
  4. #3
  5. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,136
    Rep Power
    1990
    Why not do it the easy way?

    Code:
    .center{
        text-align: center;
    }
    Code:
    <p class="center"><img ... /></p>
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    66
    Rep Power
    3
    great thanks DD

IMN logo majestic logo threadwatch logo seochat tools logo