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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts

    set images position in a container

    Hello;
    i'd like to ask you how to set the smiles of the images to the center of a container? please.


    my code as following;

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
    <html> 
    <head> 
    <title>welcome to my page</title> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"> 
    <style type="text/css"> 
    
    #container
    {
     padding: 1px;
     border: 1px;
     width: 150px;
     background-color: lightblue;
     margin: auto;
     }
    
    #container p
    {
    padding: 0;
    margin: 0;
    text-align: center;
    }
    
    #smile ul
    {
    margin-left: 0;
    padding: 0;
    text-align: center;
    }
    
    #container li
    {
    display: inline;
    list-style: none;
    text-align: center;
    margin:0;
    padding: 0;
    }
    
    #container img
    {
    margin: 0;
    padding: 0;
    }
    
    </style>
    </head> 
    <body> 
    
    <div id= "container">
    <p> smile </p>
    <ul id="sul">
    <li> <img alt="h" src="honorhim.jpg" >
    <li> <img alt="c" src="cool.gif" >
    <li> <img alt="t" src="tongue.gif">
    <li> <img alt="s" src="smile.jpg">
    <li> <img alt="z" src="zall_coho.gif">
    <li> <img alt="b" src="biggrin.gif">
    <li> <img alt="con" src="cool.gif">
    <li> <img alt="r" src="razz.gif">
    </ul>
    </div>
    </body> 
    </html>

  • #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,707
    Thanks
    0
    Thanked 237 Times in 232 Posts
    Hi there kamkam,

    it would be helpful, if we could know the image dimensions.

    coothead

  • #3
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts
    for example, the height is 20px, width is 20px.

  • #4
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,707
    Thanks
    0
    Thanked 237 Times in 232 Posts
    Hi there kamkam,

    Eight images with width and height dimensions of 20px will not fit in a container of width 150px.
    So try it like this...
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
    "http://www.w3.org/TR/html4/strict.dtd"> 
    <html> 
    <head> 
    <title>welcome to my page</title> 
    <meta http-equiv="content-type" content="text/html; charset=utf-8"> 
    <style type="text/css"> 
    #container {
        padding:2px;
        border:1px;
        width:176px;
        background-color:#add8e6;
        margin:auto;
     }
    #container:after {
        content:'';
        display:block;
        clear:both;
     }
    #container p {
        padding:0;
        margin:0;
        text-align:center;
     }
    #container ul {
        margin-left:0;
        padding:0;
     }
    #container li {
        display:inline;
        list-style:none;
        margin:0;
        padding:0;
     }
    #container img {
        float:left;
        width:20px;
        height:20px;
        margin:0 1px;;
        padding:0;
     }
    </style>
    
    </head> 
    <body> 
    
    <div id="container">
    <p>smile</p>
    <ul id="sul">
    <li><img alt="h" src="honorhim.jpg"/></li>
    <li><img alt="c" src="cool.gif"/></li>
    <li><img alt="t" src="tongue.gif"/></li>
    <li><img alt="s" src="smile.jpg"/></li>
    <li><img alt="z" src="zall_coho.gif"/></li>
    <li><img alt="b" src="biggrin.gif"/></li>
    <li><img alt="con" src="cool.gif"/></li>
    <li><img alt="r" src="razz.gif"/></li>
    </ul>
    </div>
    
    </body> 
    </html>
    coothead

  • #5
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Thanks for your help, it is very helpfull.

  • #6
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,707
    Thanks
    0
    Thanked 237 Times in 232 Posts
    No problem, you're welcome.


  •  

    Posting Permissions

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