I'm trying to make a website with some divs that hold images / text, the layout looks something like this:
(i cant post more than 2 links, hence the text example. the divs are centered.)
-
- -
- -
- -
When i make the browser smaller the divs should line up under each other, like this:
but with my code it will look like this:
i've tried various things but none of them resulted in the first div being perfectly alligned in both situations.
html source:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Sinterklaas website</title>
</head>
<body style="background-color:black">
<center><div class = "secondary"></div></center>
<center>
<div class="main">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td colspan="2" height="180px">
<a href="http://www.google.nl">
<img style="display:block;" width="100%" height="100%" src="arduino.jpg" />
</a>
</td>
</tr>
<tr>
<td colspan="1" bgcolor="blue" width="220px"></td>
<td bgcolor="green"></td>
</tr>
</table>
</div>
<div class="main" id="second">
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
<tr>
<td colspan="2" height="180px">
<a href="http://www.google.nl">
<img style="display:block;" width="100%" height="100%" src="arduino.jpg" />
</a>
</td>
</tr>
<tr>
<td colspan="1" bgcolor="blue" width="220px"></td>
<td bgcolor="green"></td>
</tr>
</table>
</div>
</center>
<center>
<div class="main"></div>
<div class="main"></div>
</center>
<center>
<div class="main"></div>
<div class="main"></div>
</center>
</body>
css source:
body {
background-image: url("background.jpg");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
.main {
background-color: red;
display: inline-block;
position: relative;
width: 300px;
height: 225px;
margin: 15px;
}
.secondary {
background-color: red;
position: relative;
display: inline-block;
left: -165px;
width: 300px;
height: 70px;
margin: 0 auto;
}
.test {
background-color: red;
display: inline-block;
position: relative;
width: 300px;
height: 260px;
margin: 30px;
}
.empty {
position: relative;
display: inline-block;
background-color: red;
width: 300px;
height: 0px;
}
#first {
}
#second {
background-image: url("arduino.jpg");
background-size: 100% 100%;
}
#third {
}
#fourth {
}
#fifth {
}
#sixth {
}
any help would really be appreciated!