Skip navigation
Currently Being Moderated

resizing images in a div to fit browser width

Apr 12, 2012 1:34 PM

i have a page with rollovers in a DIV:

 

http://toddheymandirector.com/REEL/index_newlook.html

 

i want the the images, "nike the getaway", etc, to resize to fit the browser window width. i tried putting them in a div and adding

}

row {

    max-width: 100%;

    height: auto;

    width: auto\9; /* ie8 */

}

 

but it didnt work..

 

ideas?

thanks

 
Replies
  • Currently Being Moderated
    Apr 12, 2012 2:15 PM   in reply to reelhero

    My aim is to be constructive here.

     

    Did you know that, next to uninvited sound, the thing visitors dislike most is a horizontal scroll bar?

    Your current layout is a screen and a half wide.

     

    Are you aware that ther is not a single word of content for Google to rank and drive traffic to your site?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 2:48 PM   in reply to reelhero

    Sorry, I made a silly assumption you were seeking to expand you images, rather than shrink them.

    I know of no way to line up all those 300px wide images in a let's say 980px container and have them fit.

     

    My suggestion would be to rearrange them, use thumbnails with disjointed full-size rollovers,

    or use a gimmick like Photostack,  Carousel, or a javascript zoom.

     

    If you can't fine these, I'll find them for you

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 4:05 PM   in reply to reelhero

    You could try something like the below. Basically it will show a maximum of 4 images per row (25%) so:

    • if your image width is 300px, for the browser to view all 4 at 100% their window needs to be 1200px wide
    • if their browser window is smaller than 1200px, the images will start to move onto new rows
    • if the browser window is bigger than 1200px, it will scale the 4 up to fit the width.

     

    You can change the width of the images to match your optimal browser window and/or change the percentages to see the effect it has.

    Eg, if you remove the "min-width:25%;" from #gallery ul li it will not scale the images at all. If you change "min-width:25%;" to "width:25%;", it will always show 4 images in a row and scale up or down to fit the window.

     

    Best thing to do is play around until you're happy. Good luck.

     

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body{
        background-color:#666666;
        margin:0;
        padding:0;
    }
    
    #container{
        width:100%;
        height:auto;
        margin:0;
        padding:0;
    }
    
    #title{
        width:100%;
        float:left;
        color:#FFFFFF;
        font-family:Arial, Helvetica, sans-serif;
        font-size:140%;
        line-height:150%;
        margin-bottom:30px;
        text-align:center;
    }
    
    #gallery{
        width:100%;
        height:auto;
        margin:0;
        padding:0;
        float:left;
    }
    
    #gallery ul{
        width:100%;
        height:auto;
        margin:0;
        padding:0;
        float:left;
        background-color:#666666;
        list-style-type:none;
    }
    
    #gallery ul li{
        min-width:25%;
        display:block;
        margin:0;
        padding:0;
        float:left;
        background-color:#666666;
    }
    
    img{
        display:block;
        border:none;
        margin:0;
        padding:0;
        width:100%;
    }
    </style>
    </head>
    
    <body>
    <div id="container">
    <div id="title">This is a floating web gallery</div>
    <div id="gallery">
    <ul>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    <li><img src="nike.png" /></li>
    </ul>
    </div>
    </div>
    </body>
    </html>

     

    DW_floatScale_Gallery.jpgDW_floatScale_GalleryLG.jpg

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 5:17 PM   in reply to reelhero

    I see you changed the Doctype to HTML 5. If that is what you are planning, then there might be a better way of pulling them together:

     

    <!DOCTYPE>
    <html>
    <head>
    <meta content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body {
        background-color:#666666;
        margin:0;
        padding:0;
        font-family:Arial, Helvetica, sans-serif;
        color:#FFFFFF;
    }
    #container {
        width:100%;
        height:auto;
        margin:0;
        padding:0;
    }
    #title {
        width:100%;
        float:left;
        font-size:140%;
        line-height:150%;
        margin-bottom:30px;
        text-align:center;
    }
    #gallery {
        width:100%;
        height:auto;
        margin:0;
        padding:0;
        float:left;
    }
    
    figure {
        min-width:25%;
        margin:0;
        padding:0;
        float:left;
        background-color:#666666;
    }
    figcaption {
        font-size:100%;
    }
    img {
        display:block;
        border:1px solid #FFFFFF;
        margin-bottom:5px;
        padding:0;
        width:100%;
    }
    </style>
    </head>
    
    <body>
    <div id="container">
      <div id="title">This is a floating web gallery</div>
      <section id="gallery">
        <figure> <img src="nike.png" />
          <figcaption>This is an image</figcaption>
        </figure>
        <figure> <img src="nike.png" />
          <figcaption>This is an image</figcaption>
        </figure>
        <figure> <img src="nike.png" />
          <figcaption>This is an image</figcaption>
        </figure>
        <figure> <img src="nike.png" />
          <figcaption>This is an image</figcaption>
        </figure>
        <figure> <img src="nike.png" />
          <figcaption>This is an image</figcaption>
        </figure>
        <figure> <img src="nike.png" />
          <figcaption>This is an image</figcaption>
        </figure>
        <figure> <img src="nike.png" />
          <figcaption>This is an image</figcaption>
        </figure>
        <figure> <img src="nike.png" />
          <figcaption>This is an image</figcaption>
        </figure>
      </section>
    </div>
    </body>
    </html>

     

    You can then link each image to open the video as a lightbox. Try: http://videolightbox.com/

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 12, 2012 5:53 PM   in reply to reelhero

    Hey Todd,

    Re-scaling seems to work best with one image inside a liquid (% based) container.   You cannot do this successfully with absolutely positioned elements.

    http://alt-web.com/TEMPLATES/ResponsiveDesign1.shtml

     

     

     

     

    Nancy O.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points