-3

这就是我想做的: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>
4

2 回答 2

2

您还应该告诉我们使用的浏览器...如果您使用 chrome 或 firefox 和 firebug,请打开调试器(使用 chrome 的 ctrl+shift+j)并尝试实时编辑样式,以本地化您的问题。

于 2013-01-04T15:23:31.333 回答
1

演示

HTML

<div id="top-left">
    <div id="ff">Firefox</div>
    <div id="am">About me</div>
</div>
<div id="top-right">
    <div id="bp">Box Photos</div>
</div>
<div id="bottom">
    <div id="fb">Facebook</div>
    <div id="pj">Projects</div>
    <div class="sk">Skype</div>
    <div class="sk">Skype</div>
    <div class="sk">Skype</div>
</div>

CSS

#top-left, #top-right {
float:left;
}
#bottom {
clear:both;   
}
#ff, #am, #bp {
margin:16px 8px;
padding:8px;
height:128px;
width:240px;  
}
#ff {
background-color:orange;    
}
#am {
background-color:tan;    
}
#bp {
height:288px;
width:512px;
background-color:blue;    
}
#fb, #pj, .sk {
margin:0px 8px;
padding:8px;
height:120px;
width:120px;
float:left;
}
#fb {
background-color:navy;   
}
#pj {
background-color:maroon;
}
.sk {
background-color:lightblue;
}​
于 2013-01-04T15:35:50.263 回答