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 8 of 8
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Centering Images in a div

    How the heck are you supposed to get images centered within a div if the center tag has been deprecated?

    Code:
    <div id="otherlinks">
    	<span class="smallText">Proud member of ICEA</span>
    		
    	<span class="logospan"><a href="http://www.iceaweb.org/mc/page.do" target="_blank"><img src="icealogo.gif" width="60" height="45" alt="ICEA Logo" /></a></span>
    	<span class="smallText">Eagle River Chamber of Commerce</span>
    	    <span class="logospan"><img src="coclogo.jpeg" width="60" height="45" alt="COC Logo" /></span>
    	<span class="smallText">Traingle Concierge-Consulting and Training</span>
    	<span class="logospan"><a href="http://www.triangleconcierge.com" target="_blank"><img src="conciergedir.jpg" width="60" height="45" alt="Traingle Logo" /></a></span>
    </div>
    Code:
    .smallText
    	{    
    	 font-family:verdana;	
    	 font-size:.6em;
    	 text-align:center;
    	}
    
    .logospan
    	{
    	 text-align:center;
    	 border:none;
    	}
    Thanks.
    Scott Stewart
    Always happy to learn from pros.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,476
    Thanks
    6
    Thanked 980 Times in 953 Posts
    Quote Originally Posted by ScottInTexas View Post
    How the heck are you supposed to get images centered within a div if the center tag has been deprecated?
    With text-align: center; applied to the parent element (the div in your case). All inline content (i.e. text and elements) can be centered like that.

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Thanks VIP,

    The div css is below. It is set text-align:center. That's why I'm going nuts!
    Code:
    div#otherlinks
    	{
    	 position:absolute;	
    	 top:37.5%;	
    	 left:0;	
    	 width:14.4%;	
    	 height:25%;
    	 text-align:center;	 
    	}
    Scott Stewart
    Always happy to learn from pros.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    That should work so that means there is likely something else not allowing you to center your images. Can you post the rest of your CSS or a link to your site please? I'm guessing you some how made your images display:block.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Sorry if I'm hijacking this thread, but does the "text-align:center;" tag also apply to the divs INSIDE that div? Cause I can't seem to get that work.

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    No text-align:center; only applies to inline elements like links, spans, and images. To get a div centered inside of another div you need to use margin:auto; on the div inside of the parent div. IE6 (not sure about IE7) will incorrectly center a block level element if its parent element has text-align:center;
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    CaptainB (09-27-2007)

  • #7
    Regular Coder
    Join Date
    Jun 2007
    Posts
    805
    Thanks
    123
    Thanked 23 Times in 23 Posts
    Thanks _Aerospace_Eng_, now it makes scence! I have been wondering about that for some time now, cause every time I try, it dosn't work. Now I get it

    EDIT: Lol, sorry on the name. Changed.
    Last edited by CaptainB; 09-27-2007 at 05:53 PM.

  • #8
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by CaptainB View Post
    Thanks Dave, now it makes scence! I have been wondering about that for some time now, cause every time I try, it dosn't work. Now I get it
    I'm not Dave but you're welcome.
    ||||If you are getting paid to do a job, don't ask for help on 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
    •