这就是我想做的:http: //www.prikachi.com/images/743/5697743V.png
但是当我尝试制作它时,我得到了这个: http: //www.prikachi.com/images/742/ 5697742I.png
我怎样才能使它成为可能?我不使用桌子。
有很好的例子如何制作带有地铁主题的网页,但我不想使用 jQuery 或 JavaScript。抱歉,如果有类似的问题,但我找不到。谢谢 :)
样式.css
@font-face{
font-family: OpenSans;
src: url("opensans-light.ttf");
}
body{
background-color: #260930;
font-family: OpenSans;
}
header{
color: white;
font-size: 48px;
}
footer{
text-align: center;
color: white;
font-size: 12px;
}
.content{
height: 80%;
overflow: hidden;
}
.content .items{
padding: 0 20px;
position: relative;
overflow: hidden;
}
.icons{
position: relative;
top: 50%;
left: 50%;
}
.box{
float: left;
position: relative;
margin: 8px;
padding: 8px;
background: #555;
text-decoration: none;
cursor: pointer;
overflow: hidden;
color: #fff;
background: #00a8ec;
z-index: 9;
width: 240px;
height: 128px;
}
.box:hover{
opacity: 0.85;
}
.box span{
color: white;
position: absolute;
left: 5px;
bottom: 5px;
font-size: 15px;
font-weight: normal;
z-index: 8;
}
.box img{
position: absolute;
left: 50%;
top: 50%;
margin-left: -32px;
margin-top: -32px;
z-index: 7;
}
.box img.cover{
position: absolute;
margin: 0 auto;
top: 0px;
left: 0px;
width: 100%;
z-index: 6;
}
.photos{
width: 512px;
height: 288px;
}
.width1{width: 120px;}
.height1{height: 120px;}
索引.html:
<!DOCTYPE HTML>
<html>
<head>
<title>Metro theme site</title>
<link rel="stylesheet" href="style.css"/>
<meta charset="windows-1251"/>
</head>
<body>
<div class="content">
<div class="items">
<a href="#" class="box" style="background: #f58d00;">
<span>Firefox</span>
<img src="images/firefox.png" alt="" />
</a>
<a href="#" class="box" style="background: #d68a3a; top: auto;">
<span>About me</span>
<img src="images/aboutme.png" alt="" />
</a>
<a class="box photos" style="box-align: start;" href="#">
<span>Photos</span>
<img class="cover" src="http://www.hdwallpapersarena.com/wp-content/uploads/2012/04/HD-wallpaper-2.jpeg" alt="" />
</a>
<a href="http://www.facebook.com/megapro189" target="_blank" class="box width1 height1" style="background: #3b5a9b;">
<span>Facebook</span>
<img src="images/facebook.png" alt="" />
</a>
<a href="#" class="box width1 height1" style="background: #f21d1d;">
<span>Projects</span>
<img src="images/projects.png" alt="" />
</a>
<a href="#" class="box width1 height1" style="background: #00aaf1;">
<span>Skype</span>
<img src="images/skype.png" alt="" />
</a>
<a href="#" class="box width1 height1" style="background: #00aaf1;">
<span>Skype</span>
<img src="images/skype.png" alt="" />
</a>
<a href="#" class="box width1 height1" style="background: #00aaf1;">
<span>Skype</span>
<img src="images/skype.png" alt="" />
</a>
</div>
</div>
</body>
</html>