views:

54

answers:

2

I've got 5 images I'd like to organize in an ASP.NET MVC view. So what I need is an HTML+CSS solution (I prefer not to use jQuery for this, for maximal compatibility).

I want to organize the images like so:

  Image1           Image2

  Image3           Image4

           Image5

At first I tried using tables, with the HTML being:

           <div class="table1">
            <table border=1>
              <tbody>
                <tr>
                  <td>
                      <img class="mainArticleImage" src="../../images/fixedImages/dr_teman_Articles_Body.Contouring.jpg" />
                  </td>
                  <td>
                  <p class="ImageCenterContainer">
                      <img class="mainArticleImage" src="../../images/fixedImages/dr_teman_Articles_Breast.jpg" />
                  </p>
                  </td>
                  </tr>
              </tbody>
            </table>            
            </div>                    
            <div class="table2">
            <table border=1>
              <tbody>
                <tr>
                  <td>
                  <p class="ImageCenterContainer">
                      <img class="mainArticleImage" src="../../images/fixedImages/dr_teman_Articles_Skin.jpg" />
                  </p>
                  </td>
                  <td>
                  <p class="ImageCenterContainer">
                      <img class="mainArticleImage" src="../../images/fixedImages/Dr_teman_Articles_Face.jpg" />
                  </p>
                  </td>
                </tr>
              </tbody>
            </table>            
            </div>
            <div class="table3">
            <table border=5>
              <tbody>
                <tr>
                  <td>
                  <p class="ImageCenterContainer">
                      <img class="mainArticleImage" alt="" src="../../images/fixedImages/Dr_teman_Articles_Face.jpg" />
                  </p>
                  </td>
                </tr>
              </tbody>
            </table>            
            </div> 

and the css part:

    .mainArticleImage 
{

    height: 95px;
    width: 120px;
}



.ImageCenterContainer
{
    margin: 0 auto;
    margin-top:0px;
    margin-bottom:0px;
    padding:0px;
    text-align:center;
}

but that doesn't work on IE.

This approach also didn't work too well either.

What is the best, simplest, cross-browser way to carry out what would seem to be an easy task?

+2  A: 

How about this: http://jsfiddle.net/um6d7/

Brian Flanagan
also - works great in chrome, but doesn't in IE (all the images aren't getting resized, so you get a column of huge pictures)
Tom Teman
Huh. It works exactly as I expected in my ie. Is it possible your ie isn't working correctly? Which version of ie are you using?
Brian Flanagan
+1 for finding Nemo
Alec
A: 

@Brian Flanagan (this reply was too long for a comment)

I'm using IE8, but this solution should work for older IE versions as well. Shouldn't it to be fairly simple to organize 5 pictures on a screen? :-P

I should also mention that I didn't copy and paste your solution "as is", since I didn't want my css to refer to general tags such as "img" and "div", but the changes are meaningless in terms of logic. The actual code I used:

HTML:

<div id="imagesContainer">
<img class="articleImage" src="http://upload.wikimedia.org/wikipedia/commons/1/18/Ocellaris_clownfish.JPG" />
<img class="articleImage" src="http://upload.wikimedia.org/wikipedia/commons/1/18/Ocellaris_clownfish.JPG" />
<img class="articleImage" src="http://upload.wikimedia.org/wikipedia/commons/1/18/Ocellaris_clownfish.JPG" />
<img class="articleImage" src="http://upload.wikimedia.org/wikipedia/commons/1/18/Ocellaris_clownfish.JPG" />
<img class="articleImage middle" src="http://upload.wikimedia.org/wikipedia/commons/1/18/Ocellaris_clownfish.JPG"/&gt;
</div>​

CSS:

#imagesContainer {width:550px; overflow:hidden;}
.articleImage {width:180px; float:left; display:inline; margin:15px;}
.middle {margin:15px 90px;}

any suggestions?

Tom Teman
Yeah, I'm really starting to think there's something up with your ie8. I pasted your code into a new jsfiddle (http://jsfiddle.net/MQGEe/) and fired up in ie8, 7, and 6. All rendered exactly the same on my machine.
Brian Flanagan
I apologize on behalf of Microsoft. My explorer needed me to close it and reopen it to display changes in code. That or CTRL+F5.In the end I changed the direction of the look, but thank you. Along the way I think I became better equipped for handling IE/everyone-else browser compatibility.Thank you!
Tom Teman