www.webdeveloper.com
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2012
    Posts
    1

    CSS Image Floating

    Hey guys,

    I'm making my own site and I want to position a number of images right next to each other like the ones in this site : http://www.cutestpaw.com/

    So far I've got to here: http://img15.imageshack.us/img15/9751/blahp.png
    and I don't know how to remove the space marked with red.

    Here's my code so far:
    HTML Code:
    <style type='text/css'>
    #gallery img {
    	vertical-align: top;
    	display: block;
    	margin: 0px;
    	padding: 0px;
    	width: 290px;
    	float: left;
    }
    </style>
    <div id='gallery'>
    <img src='...' />
    <img src='...' />
    <img src='...' />
    ...
    </div>
    Any help woud be really appreciated :]

  2. #2
    Join Date
    Dec 2011
    Posts
    74
    Unfortunately I am unable to view that page from my location. Can you set up an example at http://jsfiddle.net/?

  3. #3
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242
    You need to arrange things in columns to get what you want. Here's a fiddle showing that. Replace the colored divs with imgs. Here's the code:
    Code:
    .col {width:200px;float:left;}
    .red {background-color:red; width:200px; height:155px; }
    .green {background-color:green; width:200px; height:105px; }
    .blue {background-color:blue; width:200px; height:135px; }
    .yellow {background-color:yellow; width:200px; height:75px; }
    HTML Code:
    <div class="col">
        <div class="red"></div>
        <div class="green"></div>
        <div class="blue"></div>
    </div>
    <div class="col">
        <div class="blue"></div>
        <div class="yellow"></div>
        <div class="red"></div>
    </div>
    You don't have to float the imgs or anything (you do have to float the columns). Just make sure the width of the imgs is the same as the columns and they'll stack right in nicely.
    Last edited by handcraftedweb; 06-07-2012 at 03:42 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

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



Recent Articles