
Originally Posted by
Pamela1991
Well, I put in the .dummy div because that was the only way I was able to make perfect squares. Did I over-complicate my code by using 3 divs (.headline1, .dummy, .headline) all just for the purpose of getting one perfect square?
Ah ok, I see what you were doing.
You could do it like this then.
Code:
<!DOCTYPE HTML>
<html>
<head>
<title>Testing</title>
<meta charset="utf-8">
<link type="text/css" href="style.css" rel="stylesheet" media="all">
<title>Untitled Document</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html, body {
background: #ccc;
font: 13px/1.231 arial, helvetica, clean, sans-serif
}
body { text-align: center; }
#container {
margin: 0 auto;
width: 100%;
}
#header {
background: #ccc;
width: 100%;
height: 100px;
}
#page {
width: 100%;
background: white;
overflow: hidden;/*height: 1%;*/
position:relative;
}
.headline {
position: relative;
width: 12.5%;
float: left;
border: 3px solid black;
background: #eee;
position:relative;
z-index:2;
}
.head1 {width: 25%}
.headline b { margin-top: 100%;display:block;zoom:1.0}
.headline a {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
a.white-space-link{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
z-index:1;
}
span{
position:relative;
margin-top:50%;
display:block;
}
</style>
</head>
<body>
<div id="container">
<div id="header"> </div>
<div id="page">
<div class="headline head1">
<b></b><a href="link1"><span>Link 1</span></a>
</div>
<div class="headline">
<b></b><a href="link2"><span> Link 2</span></a>
</div>
<div class="headline">
<b></b><a href="link3"><span> Link 3</span></a>
</div>
<a class="white-space-link" href="http://www.google.com"></a>
</div>
</div>
</body>
</html>
That should work back to Ie7 (not ie6 though). If you only wanted ie8+ support then you could remove one element and do it like this:
Code:
<!DOCTYPE HTML>
<html>
<head>
<title>Testing</title>
<meta charset="utf-8">
<link type="text/css" href="style.css" rel="stylesheet" media="all">
<title>Untitled Document</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html, body {
background: #ccc;
font: 13px/1.231 arial, helvetica, clean, sans-serif
}
body { text-align: center; }
#container {
margin: 0 auto;
width: 100%;
}
#header {
background: #ccc;
width: 100%;
height: 100px;
}
#page {
width: 100%;
background: white;
overflow: hidden;/*height: 1%;*/
position:relative;
}
.headline {
position: relative;
width: 12.5%;
float: left;
border: 3px solid black;
background: #eee;
position:relative;
z-index:2;
}
.head1 {width: 25%}
.headline a {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.headline:after{
content:" ";
display:block;
margin-top: 100%;
}
a.white-space-link{
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
z-index:1;
}
span{
position:relative;
margin-top:50%;
display:block;
}
</style>
</head>
<body>
<div id="container">
<div id="header"> </div>
<div id="page">
<div class="headline head1">
<a href="link1"><span>Link 1</span></a>
</div>
<div class="headline">
<a href="link2"><span> Link 2</span></a>
</div>
<div class="headline">
<a href="link3"><span> Link 3</span></a>
</div>
<a class="white-space-link" href="http://www.google.com"></a>
</div>
</div>
</body>
</html>
The inner span is only to move the link text to the middle and can also be removed if that isn't a requirement.
Bookmarks