overflow property using css - html

I tried to use property overflow-x:scroll in css property but it does not work at all but overflow-y:scroll works in the same div. I want to use overflow for scrolling images horizontally in one specific div.
Heres my code:
html:
<div class="inner-images">
<div class="imageHolder">
<img src="images/interior2.png">
</div>
</div>
<div class="inner-images">
<div class="imageHolder">
<img src="images/house.png">
</div>
</div>
<div class="inner-images">
<div class="imageHolder">
<img src="images/house.png">
</div>
</div>
<div class="inner-images">
<div class="imageHolder">
<img src="images/house.png">
</div>
</div>
<div class="inner-images">
<div class="imageHolder">
<img src="images/house.png">
</div>
</div>
<div class="inner-images">
<div class="imageHolder">
<img src="images/house.png">
</div>
</div>
<div class="inner-images">
<div class="imageHolder">
<img src="images/house.png">
</div>
</div>
<div class="inner-images">
<div class="imageHolder">
<img src="images/house.png">
</div>
</div>
</div>
css:
.int-images{
height:85px;
overflow:scroll;
.inner-images{
padding:0px 32px;
.imageHolder{
img{
height:85px;
width:85px;
#include box-shadow(0px 1px 4px rgba(0,0,0,0.5));
display:block;
float:left;
margin-right:15px;
}
}
}
}

How about this?
.int-images {
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
.inner-images {
display: inline-block;
padding:0px 32px;
margin-right:15px;
.imageHolder {
img{
height: 85px;
width: 85px;
#include box-shadow(0px 1px 4px rgba(0,0,0,0.5));
}
}
}
}
fiddle

Try this
.int-images{
overflow:scroll;
white-space:nowrap;
}
.imageHolder img{
height:85px;
width:85px;
#include box-shadow(0px 1px 4px rgba(0,0,0,0.5));
display:inline-block;
margin-right:15px;
}
<!-- language: lang-html -->
<div class="int-images">
<div class="inner-images">
<div class="imageHolder">
<img src="images/interior1.png">
<img src="images/interior2.png">
<img src="images/house.png">
<img src="images/house.png">
<img src="images/house.png">
<img src="images/house.png">
<img src="images/house.png">
<img src="images/house.png">
<img src="images/house.png">
</div>
</div>
</div>
<!-- end snippet -->

Related

positioning in html and css not working properly

Hi I am trying to get a list of images placed one below other and on top of each image there is some text. I thought of this layout. I have a main wrapper with relative positioning which contains a img-txt div this also has relative positioning. and then this contains two divs one for image and other for text. But my images are stacked on top of each other why?
.wrapper{
position:relative;
}
.img-txt{
position: relative;
}
.iimg{
position: absolute;
}
.text{
position: absolute;
}
<div class="wrapper">
<div class="img-txt">
<div class="iimg">
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg"/>
</div>
<div class = "text">Test</div>
</div>
</div>
<div class="wrapper">
<div class="img-txt">
<div class="iimg">
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg"/>
</div>
<div class = "text">Test</div>
</div>
</div>
<div class="wrapper">
<div class="img-txt">
<div class="iimg">
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg"/>
</div>
<div class = "text">Test</div>
</div>
</div>
<div class="wrapper">
<div class="img-txt">
<div class="iimg">
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg"/>
</div>
<div class = "text">Test</div>
</div>
</div>
Edit : The text should be centered horizontally and vertically
change your .iimg to position:relative; and add z-index to the text. you can adjust text's position using top and left
.wrapper{
width:400px;
margin:0;
padding:0;
border:1px solid black;
}
.img-txt{
position: relative;
width:100%;
margin:0;
padding:0;
}
.iimg{
position:relative;
width:100%;
margin:0;
padding:0;
}
.iimg img{
width:100%;
margin:0;
padding:0;
display:block;
}
.text{
position: absolute;
top:50%;
left:50%;
z-index:10;
}
<div class="wrapper">
<div class="img-txt">
<div class="iimg">
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg"/>
</div>
<div class = "text">Test</div>
</div>
</div>
<div class="wrapper">
<div class="img-txt">
<div class="iimg">
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg"/>
</div>
<div class = "text">Test</div>
</div>
</div>
<div class="wrapper">
<div class="img-txt">
<div class="iimg">
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg"/>
</div>
<div class = "text">Test</div>
</div>
</div>
<div class="wrapper">
<div class="img-txt">
<div class="iimg">
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg"/>
</div>
<div class = "text">Test</div>
</div>
</div>
Here. Proper markup, and CSS.
ul {
list-style-type: none;
}
li {
position: relative;
display: inline-block;
}
li span {
position: absolute;
top: 0;
left: 0;
right: 0;
margin-top: 25%;
text-align: center;
z-index: 100;
visibility: hidden;
}
li:hover span,img:hover ~ span {
visibility: visible;
}
<ul class="wrapper">
<li>
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg">
<span>Test</span>
</li>
<li>
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg">
<span>Test</span>
</li>
<li>
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg">
<span>Test</span>
</li>
<li>
<img src="http://img.youtube.com/vi/rMcW62wx1Qk/mqdefault.jpg">
<span>Test</span>
</li>
</ul>
You can use min height if you know the height of the images but not for images with unknown heights
.wrapper{
min-height: 300px;
}

Only want to display 4 divs in a row rather than 5

What I need is for only 4 boxes in each row with 3 rows total. Right now it's displaying 5,5,2. I had it working correctly but after adding some code I did something to mess it up. Any help would be appreciated.
Here is a link to see my current code displayed. http://bakersfieldtopagents.com/zipcode-search/.
<style>
.title {font-size:40px; text-align:center;}
.zipcodebox { display:inline-block; vertical-align:top;}
.zipcodeboxxtra { display:inline; z-index:1; position:relative; margin-top:-20px; float:right; margin-right:107px; vertical-align:top;}
.zipcode {color:#FFFFFF; font-size:60px; z-index:2; position: absolute; margin-left:80px; margin-top:55px;
-ms-transform: rotate(25deg); /* IE 9 */
-webkit-transform: rotate(25deg); /* Chrome, Safari, Opera */
transform: rotate(25deg);}
.zipcodeother {color:#FFFFFF; font-size:60px; z-index:2; position: absolute; margin-left:30px; margin-top:55px;
-ms-transform: rotate(25deg); /* IE 9 */
-webkit-transform: rotate(25deg); /* Chrome, Safari, Opera */
transform: rotate(25deg);}
.zipcodeboximage img {height:100%; width:100%; max-height:200px; max-width:300px; padding-right:10px; padding-left:10px; z-index:1; position: relative;}
.zipcodeboxtitle {background-color:#0F0A42; color:#FFFFFF; line-height: 1; font-size: 1.6em; text-align:center; font-family: sans-serif; max-width:280px; width:100%; margin-top:0px; margin-left:0px; padding:10px;}
.zipcodeboxtitle a {color:#FFFFFF;}
.zipcodeboxtitlextra1 a {background-color:#0F0A42; color:#FFFFFF; line-height: 1; font-size: 1.6em; text-align:center; font-family: sans-serif; width:280px; padding:10px; display:block; border-bottom: 1px solid #000000;}
.zipcodeboxtitlextra2 a {background-color:#0F0A42; color:#FFFFFF; line-height: 1; font-size: 1.6em; text-align:center; font-family: sans-serif; width:280px; padding:10px; display:block; border-bottom: 1px solid #000000;}
.zipcodeboxtitlextra3 a {background-color:#0F0A42; color:#FFFFFF; line-height: 1; font-size: 1.6em; text-align:center; font-family: sans-serif; width:280px; padding:10px; display:block; border-bottom: 1px solid #000000;}
.zipcodeboxtitlextra4 a {background-color:#0F0A42; color:#FFFFFF; line-height: 1; font-size: 1.6em; text-align:center; font-family: sans-serif; width:280px; padding:10px; display:block;}
</style>
<div class="title">Search Homes By Zipcode</div>
<center>
<div class="zipcodebox">
<div class="zipcode">93312</div>
<div class="zipcodeboximage"><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93314</div>
<div class="zipcodeboximage"><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93311</div>
<div class="zipcodeboximage"><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93313</div>
<div class="zipcodeboximage"><a href=""><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93309</div>
<div class="zipcodeboximage"><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93301</div>
<div class="zipcodeboximage"><img src=""></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93304</div>
<div class="zipcodeboximage"><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93308</div>
<div class="zipcodeboximage"><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93306</div>
<div class="zipcodeboximage"><img src="http://bakersfieldtopagents.com/wp-content/uploads/2016/08/cityimage.jpg" alt="zipcode"></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93305</div>
<div class="zipcodeboximage"><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitle"><a href="">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcode">93307</div>
<div class="zipcodeboximage"><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitle">AREA TITLE</div>
</div>
<div class="zipcodebox">
<div class="zipcodeother">Other Areas</div>
<div class="zipcodeboximage"><img src="" alt="zipcode"></div>
<div class="zipcodeboxtitlextra1">AREA TITLE</div>
<div class="zipcodeboxtitlextra2">AREA TITLE</div>
<div class="zipcodeboxtitlextra3">AREA TITLE</div>
<div class="zipcodeboxtitlextra4">AREA TITLE</div>
</div>
<div class="title">Search Homes By Zipcode</div>
</center>
Because of this property set to zipcodebox class : "display:inline-block;"
Number of divs in a row will change according to the screen resolution and size.
If you want to have fixed number of divs in each row then do :
Then you need to define width of zipcodebox in percentage:
eg: width : 20%
PS: It will not be responsive.
I fixed this by simply adding .container {max-width:95%;} to the css and a container div to the html. It works and is responsive.

words need to be more appart from eachother and more in the middle of the screen..

This might seem rather easy to solve, but I couldn't find an answer on stackoverflow nor anywhere on the internet to solve my little problem..
I need these http://prntscr.com/a0y8jm words to be more in the middle of the screen, and I need to be able to put the words more appart from eachother, I first used Padding, but I don't really think that works out so well, and the words aren't responding on padding anymore eighter (because I made the layout different)
anyone got any tips on how to make this work, and if you have some tips for the other parts of my code, those are always welcome too. I am not in programming that long yet, so I could use all the information I can get :)
This is my code,
body, html {
margin-left: 10%;
margin-right: 10%;
padding: 0px;
height: 100%;
font-family: georgia, "Comic Sans MS";
background-color: #f0f0f0;
}
header {
height: 5%;
border-bottom: thick solid grey;
}
.img {
width: 25%;
height: 30%;
background-color:#f0f0f0;
float: left;
}
.antwoord {
float: left;
width: 95%;
height: 25px;
background-color: white;
border-style: solid;
border-color: #000000;
border-width: 4px;
}
.move1 {
}
.move2 {
margin-top: 12.5%
}
.move4 {
margin-top: 19%
}
.move5 {
margin-top: 33.5%
}
.move6 {
margin-top: 20.8%
}
.move7 {
margin-top: 37.5%
}
.word, .word .tekst, .word p {
display: inline;
}
.my-row{
clear: both;
}
.answers .word, .answers .word2{
float: left;
padding: 3px;
width: 100px;
}
footer {
border-top: thick solid grey;
height: 5%;
display : table-row;
vertical-align : bottom;
}
.points {
float: right;
}
.container {
height:100%;
border-collapse:collapse;
display : table;
}
.igen {
font-size: 25px;
font-weight: bold;
}
.sprint {
float: right;
}
.copyright {
position: relative;
bottom: 20px;
left: 65px;
font-size: 10px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Words</title>
<link rel="stylesheet" href="css/style.css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<script>
</script>
</head>
<body>
<header>
<span class="fa fa-refresh" style="font-size:25px;"></span><span class="igen"> igen</span>
<span class="points"><i class="fa fa-thumbs-o-up" style="font-size:24px"></i>Rigtige: 0 <i class="fa fa-thumbs-o-down" style="font-size:24px"></i>Forkerte: 0</span>
</header>
<div class="container">
<div class="img" id="img1">
<div class="plaatje" id="plaatje1"><center><img src="img/cat.jpg" alt="cat" width="50%;"></div>
<div class="move1"><div class="antwoord" id="antwoord1"></div></div>
</div>
<div class="img" id="img2">
<div class="plaatje" id="plaatje1"><center><img src="img/beak.jpg" alt="beak" width="50%;"></div>
<div class="move2"><div class="antwoord" id="antwoord2"></div></div>
</div>
<div class="img" id="img3">
<div class="plaatje" id="plaatje3"><center><img src="img/spoon.jpg" alt="spoon" width="50%;"></div>
<div class="move3"><div class="antwoord" id="antwoord3"></div></div>
</div>
<div class="img" id="img4">
<div class="plaatje" id="plaatje4"><center><img src="img/milk.jpg" alt="milk" width="50%;"></div>
<div class="move4"><div class="antwoord" id="antwoord4"></div></div>
</div>
<div class="img" id="img5">
<div class="plaatje" id="plaatje5"><center><img src="img/egg.jpg" alt="egg" width="50%;"></div>
<div class="move5"><div class="antwoord" id="antwoord5"></div></div>
</div>
<div class="img" id="img6">
<div class="plaatje" id="plaatje6"><center><img src="img/thee.jpg" alt="tea" width="50%;"></div>
<div class="move6"><div class="antwoord" id="antwoord6"></div></div>
</div>
<div class="img" id="img7">
<div class="plaatje" id="plaatje7"><center><img src="img/meel.jpg" alt="meel" width="50%;"></div>
<div class="move7"><div class="antwoord" id="antwoord7"></div></div>
</div>
<div class="img" id="img8">
<div class="plaatje" id="plaatje8"><center><img src="img/passport.jpg" alt="passport" width="50%;"></div>
<div class="move8"><div class="antwoord" id="antwoord8"></div></div>
</div>
<div class="answers">
<div class="my-row">
<div class="word" id="word1">
<div class="tekst" id="tekst1"> <p>Cat</p> </div>
</div>
<div class="word" id="word2">
<div class="tekst" id="tekst2"> <p>spoon</p> </div>
</div>
<div class="word" id="word3">
<div class="tekst" id="tekst3"> <p>meal</p> </div>
</div>
<div class="word" id="word4">
<div class="tekst" id="tekst4"> <p>passport</p> </div>
</div>
</div>
<div class="my-row">
<div class="word2" id="word5">
<div class="tekst" id="tekst5"> <p>egg</p> </div>
</div>
<div class="word2" id="word6">
<div class="tekst" id="tekst6"> <p>beak</p> </div>
</div>
<div class="word2" id="word7">
<div class="tekst" id="tekst7"> <p>tea</p> </div>
</div>
<div class="word2" id="word8">
<div class="tekst" id="tekst8"> <p>milk</p> </div>
</div>
</div>
</div>
<footer>
<img class="dansk" id="dansk" src="img/dansk2.jpg" alt="dansk" />
<img class="sprint" id="sprint" src="img/sprint2.png" alt="sprint" />
<center><span class="copyright"> ©2013 laerdansk / FC-Sprint² Leerbedrijf bronnen </span></center>
</footer>
</body>
</html>

second word row beneath another row

I need two rows of 4 words, in total 8 words, like this
I currently have my words like this
How can I make the words egg, beak, tea and milk go in a row beneath; Cat spoon meal and passport. like that?
This is my code..
body, html {
margin-left: 10%;
margin-right: 10%;
padding: 0px;
height: 100%;
font-family: georgia, "Comic Sans MS";
background-color: #f0f0f0;
}
header {
height: 5%;
border-bottom: thick solid grey;
}
.img {
width: 25%;
height: 30%;
background-color:#f0f0f0;
float: left;
}
.antwoord {
float: left;
width: 95%;
height: 25px;
background-color: white;
border-style: solid;
border-color: #000000;
border-width: 4px;
}
.move1 {
}
.move2 {
margin-top: 12.5%
}
.move4 {
margin-top: 19%
}
.move5 {
margin-top: 33.5%
}
.move6 {
margin-top: 20.8%
}
.move7 {
margin-top: 37.5%
}
.word, .word .tekst, .word p {
display: inline;
}
.word2, .word2 .tekst, .word2 p {
}
.tekst {
padding: 4.5%;
}
footer {
border-top: thick solid grey;
height: 5%;
}
.points {
float: right;
}
.container {
width: 100%;
height: 90%;
}
.igen {
font-size: 25px;
font-weight: bold;
}
.sprint {
float: right;
}
.copyright {
position: relative;
bottom: 20px;
left: 65px;
font-size: 10px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Words</title>
<link rel="stylesheet" href="css/style.css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<script>
</script>
</head>
<body>
<header>
<span class="fa fa-refresh" style="font-size:25px;"></span><span class="igen"> igen</span>
<span class="points"><i class="fa fa-thumbs-o-up" style="font-size:24px"></i>Rigtige: 0 <i class="fa fa-thumbs-o-down" style="font-size:24px"></i>Forkerte: 0</span>
</header>
<div class="container">
<div class="img" id="img1">
<div class="plaatje" id="plaatje1"><center><img src="img/cat.jpg" alt="cat" width="50%;"></div>
<div class="move1"><div class="antwoord" id="antwoord1"></div></div>
</div>
<div class="img" id="img2">
<div class="plaatje" id="plaatje1"><center><img src="img/beak.jpg" alt="beak" width="50%;"></div>
<div class="move2"><div class="antwoord" id="antwoord2"></div></div>
</div>
<div class="img" id="img3">
<div class="plaatje" id="plaatje3"><center><img src="img/spoon.jpg" alt="spoon" width="50%;"></div>
<div class="move3"><div class="antwoord" id="antwoord3"></div></div>
</div>
<div class="img" id="img4">
<div class="plaatje" id="plaatje4"><center><img src="img/milk.jpg" alt="milk" width="50%;"></div>
<div class="move4"><div class="antwoord" id="antwoord4"></div></div>
</div>
<div class="img" id="img5">
<div class="plaatje" id="plaatje5"><center><img src="img/egg.jpg" alt="egg" width="50%;"></div>
<div class="move5"><div class="antwoord" id="antwoord5"></div></div>
</div>
<div class="img" id="img6">
<div class="plaatje" id="plaatje6"><center><img src="img/thee.jpg" alt="tea" width="50%;"></div>
<div class="move6"><div class="antwoord" id="antwoord6"></div></div>
</div>
<div class="img" id="img7">
<div class="plaatje" id="plaatje7"><center><img src="img/meel.jpg" alt="meel" width="50%;"></div>
<div class="move7"><div class="antwoord" id="antwoord7"></div></div>
</div>
<div class="img" id="img8">
<div class="plaatje" id="plaatje8"><center><img src="img/passport.jpg" alt="passport" width="50%;"></div>
<div class="move8"><div class="antwoord" id="antwoord8"></div></div>
</div>
<div class="answers">
<div class="word" id="word1">
<div class="tekst" id="tekst1"> <p>Cat</p> </div>
</div>
<div class="word" id="word2">
<div class="tekst" id="tekst2"> <p>spoon</p> </div>
</div>
<div class="word" id="word3">
<div class="tekst" id="tekst3"> <p>meal</p> </div>
</div>
<div class="word" id="word4">
<div class="tekst" id="tekst4"> <p>passport</p> </div>
</div>
<div class="word2" id="word5">
<div class="tekst" id="tekst5"> <p>egg</p> </div>
</div>
<div class="word2" id="word6">
<div class="tekst" id="tekst6"> <p>beak</p> </div>
</div>
<div class="word2" id="word7">
<div class="tekst" id="tekst7"> <p>tea</p> </div>
</div>
<div class="word2" id="word8">
<div class="tekst" id="tekst8"> <p>milk</p> </div>
</div>
</div>
<footer>
<img class="dansk" id="dansk" src="img/dansk2.jpg" alt="dansk" />
<img class="sprint" id="sprint" src="img/sprint2.png" alt="sprint" />
<center><span class="copyright"> ©2013 laerdansk / FC-Sprint² Leerbedrijf bronnen </span></center>
</footer>
</body>
</html>
if you want to keep you html structure you can use this example:
.answers .word, .answers .word2{
float: left;
padding: 3px;
width: 100px;
}
.answers .word2:nth-child(5){
clear:left;
color: red;
}
<div class="answers">
<div class="word" id="word1">
<div class="tekst" id="tekst1"> <p>Cat</p> </div>
</div>
<div class="word" id="word2">
<div class="tekst" id="tekst2"> <p>spoon</p> </div>
</div>
<div class="word" id="word3">
<div class="tekst" id="tekst3"> <p>meal</p> </div>
</div>
<div class="word" id="word4">
<div class="tekst" id="tekst4"> <p>passport</p> </div>
</div>
<div class="word2" id="word5">
<div class="tekst" id="tekst5"> <p>egg</p> </div>
</div>
<div class="word2" id="word6">
<div class="tekst" id="tekst6"> <p>beak</p> </div>
</div>
<div class="word2" id="word7">
<div class="tekst" id="tekst7"> <p>tea</p> </div>
</div>
<div class="word2" id="word8">
<div class="tekst" id="tekst8"> <p>milk</p> </div>
</div>
</div>
Notice that I colored with red your fifth element that breaks content in new row.
But I suggest you to wrap you row content in single container cause it's more maintainable and readable.
See the snippet below.
.my-row{
clear: both;
}
.answers .word, .answers .word2{
float: left;
padding: 3px;
width: 100px;
}
<div class="answers">
<div class="my-row"> <!-- ADDED WORD CONTAINER -->
<div class="word" id="word1">
<div class="tekst" id="tekst1"> <p>Cat</p> </div>
</div>
<div class="word" id="word2">
<div class="tekst" id="tekst2"> <p>spoon</p> </div>
</div>
<div class="word" id="word3">
<div class="tekst" id="tekst3"> <p>meal</p> </div>
</div>
<div class="word" id="word4">
<div class="tekst" id="tekst4"> <p>passport</p> </div>
</div>
</div>
<div class="my-row"> <!-- ADDED WORD CONTAINER -->
<div class="word2" id="word5">
<div class="tekst" id="tekst5"> <p>egg</p> </div>
</div>
<div class="word2" id="word6">
<div class="tekst" id="tekst6"> <p>beak</p> </div>
</div>
<div class="word2" id="word7">
<div class="tekst" id="tekst7"> <p>tea</p> </div>
</div>
<div class="word2" id="word8">
<div class="tekst" id="tekst8"> <p>milk</p> </div>
</div>
</div>
</div>

IE7 margin issue

and thanks for the help.
I am having a somewhat confusing issue with IE7 when using margins.
I have a contaner, and inside that container I have some floated boxes.
These boxes have margins applied, top, right, left, bottom, except the first box that has no margin on the left, and the last box that has no margin on the right.
Looks fine in all browsers except IE7, where the margin is not applying for the first element in each row (at least this is what I think is happening.
If I remove margin right in ie7 using the dev tools and then check it back on it displays correctly.
Has anyone seen anything like this before?
I am stumped.
EDIT
It appears to being caused by position:relative on the container divs. Changing this back to static fixes the margin issue, but now means my divs are mis aligned in ie7. Does anyone know why position relative would screw up margins??
NEW EDIT
Example download can be found here:
www.jimplode.co.uk/content/stackoverflow.zip
Incorrect view
Correct Margins, after unchecking and rechecking just one of the margin styles.
The HTML:
<div class="lowerContent">
<div class="mediumContentBox contentBoxMarginTop contentBoxMarginRight contentBoxMarginBottom">
<div class="expandableBox">
<div class="topLeft">
<div class="topRight">
<div class="top"></div>
</div>
</div>
<div class="middleLeft">
<div class="middleRight">
<div class="middle">
<img src="/images/frame/transparent.gif" alt="spacer"width="0" height="215" class="fl" />
<div class="textContainer">
<h1>Car Insurance</h1>
<ul>
<li>Protected NCD for life</li>
<li>NCD Accelerator</li>
<li>European Cover Included</li>
<li>Multiple Drivers and Vehicles</li>
<li>Breakdown Cover Included</li>
<li>Legal Cover Included</li>
</ul>
<div class="boxButtons">
<a class="smallButtonLeft" href="#"><span>GET A QUOTE</span></a><a class="smallButtonRight" href="#"><span>FIND OUT MORE</span></a>
</div>
</div>
<div class="imageContainer">
<img src="/images/misc/boxphoto_1.jpg" alt="box image 0" />
</div>
<div class="emptyClear"></div>
</div>
</div>
</div>
<div class="bottomLeft">
<div class="bottomRight">
<div class="bottom">
</div>
</div>
</div>
</div>
</div>
<div class="smallContentBox contentBoxMarginTop contentBoxMarginLeft contentBoxMarginRight contentBoxMarginBottom">
<div class="expandableBox">
<div class="topLeft">
<div class="topRight">
<div class="top"></div>
</div>
</div>
<div class="middleLeft">
<div class="middleRight">
<div class="middle">
<img src="/images/frame/transparent.gif" alt="spacer"width="0" height="215" class="fl" />
<div class="textContainer">
<h2>Home Insurance</h2>
<div class="imageContainer">
<img src="/images/misc/boxphoto_2.jpg" alt="box image 2" />
</div>
<ul>
<li>Working at home Equipment</li>
<li>Helmet and Leathers</li>
<li>Legal Cover</li>
<li>Caravan Cover</li>
<li>Personal Accident Cover</li>
</ul>
<div class="boxButtons">
<a class="smallButtonLeft" href="#"><span>GET A QUOTE</span></a><a class="smallButtonRight" href="#"><span>FIND OUT MORE</span></a>
</div>
</div>
<div class="emptyClear"></div>
</div>
</div>
</div>
<div class="bottomLeft">
<div class="bottomRight">
<div class="bottom">
</div>
</div>
</div>
</div>
</div>
<div class="smallContentBox contentBoxMarginTop contentBoxMarginLeft contentBoxMarginBottom">
<div class="expandableBox">
<div class="topLeft">
<div class="topRight">
<div class="top"></div>
</div>
</div>
<div class="middleLeft">
<div class="middleRight">
<div class="middle">
<img src="/images/frame/transparent.gif" alt="spacer"width="0" height="215" class="fl" />
<div class="textContainer">
<h2>Life Insurance</h2>
<div class="imageContainer">
<img src="/images/misc/boxphoto_3.jpg" alt="box image 3" />
</div>
<ul>
<li>Cover From £5 a month</li>
<li>Your loved ones protected</li>
<li>Immediate cover available</li>
<li>We search, you save</li>
</ul>
<div class="boxButtons">
<a class="smallButtonLeft" href="#"><span>GET A QUOTE</span></a><a class="smallButtonRight" href="#"><span>FIND OUT MORE</span></a>
</div>
</div>
<div class="emptyClear"></div>
</div>
</div>
</div>
<div class="bottomLeft">
<div class="bottomRight">
<div class="bottom">
</div>
</div>
</div>
</div>
</div>
<div class="emptyClear"></div>
<div class="smallContentBox contentBoxMarginTop contentBoxMarginRight">
<div class="expandableBox">
<div class="topLeft">
<div class="topRight">
<div class="top"></div>
</div>
</div>
<div class="middleLeft">
<div class="middleRight">
<div class="middle">
<img src="/images/frame/transparent.gif" alt="spacer"width="0" height="140" class="fl" />
<div class="imageContainerAlternate">
<img src="/images/misc/boxphoto_4.jpg" alt="box image 4" />
</div>
<div class="boxButtons">
<a class="smallButtonLeft" href="#"><span>GET A QUOTE</span></a><a class="smallButtonRight" href="#"><span>FIND OUT MORE</span></a>
</div>
<div class="emptyClear"></div>
</div>
</div>
</div>
<div class="bottomLeft">
<div class="bottomRight">
<div class="bottom">
</div>
</div>
</div>
</div>
</div>
<div class="smallContentBox contentBoxMarginTop contentBoxMarginRight contentBoxMarginLeft">
<div class="expandableBox">
<div class="topLeft">
<div class="topRight">
<div class="top"></div>
</div>
</div>
<div class="middleLeft">
<div class="middleRight">
<div class="middle">
<img src="/images/frame/transparent.gif" alt="spacer"width="0" height="140" class="fl" />
<div class="imageContainerAlternate">
<img src="/images/misc/boxphoto_5.jpg" alt="box image 5" />
</div>
<div class="boxButtons">
<a class="smallButtonLeft" href="#"><span>GET A QUOTE</span></a><a class="smallButtonRight" href="#"><span>FIND OUT MORE</span></a>
</div>
<div class="emptyClear"></div>
</div>
</div>
</div>
<div class="bottomLeft">
<div class="bottomRight">
<div class="bottom">
</div>
</div>
</div>
</div>
</div>
<div class="smallContentBox contentBoxMarginTop contentBoxMarginRight contentBoxMarginLeft">
<div class="expandableBox">
<div class="topLeft">
<div class="topRight">
<div class="top"></div>
</div>
</div>
<div class="middleLeft">
<div class="middleRight">
<div class="middle">
<img src="/images/frame/transparent.gif" alt="spacer"width="0" height="140" class="fl" />
<div class="imageContainerAlternate">
<img src="/images/misc/boxphoto_6.jpg" alt="box image 6" />
</div>
<div class="boxButtons">
<a class="smallButtonLeft" href="#"><span>GET A QUOTE</span></a><a class="smallButtonRight" href="#"><span>FIND OUT MORE</span></a>
</div>
<div class="emptyClear"></div>
</div>
</div>
</div>
<div class="bottomLeft">
<div class="bottomRight">
<div class="bottom">
</div>
</div>
</div>
</div>
</div>
<div class="smallContentBox contentBoxMarginTop contentBoxMarginLeft">
<div class="expandableBox">
<div class="topLeft">
<div class="topRight">
<div class="top"></div>
</div>
</div>
<div class="middleLeft">
<div class="middleRight">
<div class="middle">
<img src="/images/frame/transparent.gif" alt="spacer"width="0" height="140" class="fl" />
<div class="imageContainerAlternate">
<img src="/images/misc/boxphoto_7.jpg" alt="box image 7" />
</div>
<div class="boxButtons">
<a class="smallButtonLeft" href="#"><span>GET A QUOTE</span></a><a class="smallButtonRight" href="#"><span>FIND OUT MORE</span></a>
</div>
<div class="emptyClear"></div>
</div>
</div>
</div>
<div class="bottomLeft">
<div class="bottomRight">
<div class="bottom">
</div>
</div>
</div>
</div>
</div>
<div class="emptyClear"></div>
</div>
The CSS:
.lowerContent
{
position:relative;
margin:0px 0px 0px 0px;
}
.expandableBox
{
display:block;
width:100%;
}
.expandableBox .top
{
background-image:url("/images/backgrounds/bkg_whitebox_t.png");
background-repeat: repeat-x;
height:10px;
}
.expandableBox .topLeft
{
height:10px;
padding:0px 0px 0px 10px;
background-image:url("/images/backgrounds/bkg_whitebox_tl.png");
background-repeat: no-repeat;
background-position:left top;
}
.expandableBox .topRight
{
height:10px;
padding:0px 10px 0px 0px;
background-image:url("/images/backgrounds/bkg_whitebox_tr.png");
background-repeat: no-repeat;
background-position:right top;
}
.expandableBox .middleLeft
{
padding:0px 0px 0px 10px;
background-image:url("/images/backgrounds/bkg_whitebox_l.png");
background-repeat: repeat-y;
background-position:left top;
}
.expandableBox .middle
{
background-color:#FFFFFF;
}
.expandableBox .middleRight
{
padding:0px 10px 0px 0px;
background-image:url("/images/backgrounds/bkg_whitebox_r.png");
background-repeat: repeat-y;
background-position:right top;
}
.expandableBox .bottom
{
background-image:url("/images/backgrounds/bkg_whitebox_b.png");
background-repeat: repeat-x;
background-position:bottom;
height:10px;
margin-bottom:7px;
}
.expandableBox .bottomLeft
{
height:10px;
padding:0px 0px 0px 10px;
background-image:url("/images/backgrounds/bkg_whitebox_bl.png");
background-repeat: no-repeat;
background-position:left bottom;
}
.expandableBox .bottomRight
{
height:10px;
padding:0px 10px 0px 0px;
background-image:url("/images/backgrounds/bkg_whitebox_br.png");
background-repeat: no-repeat;
background-position:right bottom;
}
.contentBoxMarginLeft
{
margin-left:10px;
}
.contentBoxMarginRight
{
margin-right:10px;
}
.contentBoxMarginTop
{
margin-top:10px;
}
.contentBoxMarginBottom
{
margin-bottom:10px;
}
.fullContentBox
{
width:940px;
float:left;
}
.largeContentBox
{
width:700px;
float:left;
}
.mediumContentBox
{
width:460px;
float:left;
}
.smallContentBox
{
width:220px;
float:left;
}
.mediumContentBox .textContainer
{
float:left;
width:210px;
}
.mediumContentBox .imageContainer
{
float:right;
width:210px;
}
.smallContentBox .textContainer
{
}
.smallContentBox .textContainer .imageContainer
{
float:right;
padding:5px 0px 0px 0px;
}
.smallContentBox .imageContainerAlternate
{
float:left;
padding:0px 0px 0px 0px;
}
a.smallButtonLeft,
a.smallButtonRight
{
display:inline-block;
background-image:url('/images/backgrounds/bkg_sprites_buttons.png');
height:30px;
background-position:left top;
background-repeat:no-repeat;
padding:0px 10px;
line-height:23px;
color: #0F4DBC;
font-family: Arial,Helvetica,sans-serif;
font-weight: bold;
text-decoration: none;
text-transform: capitalize;
}
a.smallButtonLeft:hover
{
background-position:left -44px;
}
a.smallButtonRight
{
background-position:right -217px;
color: #4D4F52;
}
a.smallButtonRight:hover
{
background-position:right -262px;
}
.boxButtons
{
float:left;
padding:10px 0px 0px 0px;
}
.smallContentBox .boxButtons
{
width:200px;
text-align:center;
}
Thanks in advance.
Could be something to do with margins collapsing. I would tempted to only have the margin on the left, then margin-left:0 on the first one.
Alternatively, try our old friend "zoom:1" on the floated divs or the parent container. Often fixes a lot of the more obscure IE weirdness.