【发布时间】:2013-12-16 18:15:00
【问题描述】:
作为练习,我试图复制一个我喜欢并有时访问的网站,Armor Games,除了学习/改进网站设计和编程之外没有其他原因。
我不想也没有完全复制代码。我喜欢用眼睛“画”出来!我不知道该网站是由表格还是 div 制作的,但由于我到处阅读,最近在这篇很酷的文章中阅读 »From Table Hell to Div Hell - 我将使用 CSS 构建它。
当我查看不同类型的块时,它们就在主页上(推广游戏;新游戏;最新任务等),我试图弄清楚它的结构。
例如,标题。我认为这是一张背景图片,在背景之上是 acc 注册和登录代码(这是我现在不会担心的)。
但是,我也读到“(...) 标题应该用 h1 到 h5 标签包装。编写语义代码通常会减少代码库;使用浮点数减少 div 有助于避免浏览器错误。" - 所以,我不想让您编写代码,只是提示一下,例如,“Promoted Games”块的结构! (2个div?)
如果你能快速浏览一下这个网站,那么下面是我的 xP 版本,
HTML
<body>
<div id="MainMainBlock">
<div id="MainBlock">
<div id="Header">
<center>
Armor Games Header, Login and Acc Registration
</center>
</div>
<div id="Categories">
[Several Categories and other clickables!] -
[Random Game] - [Quests]
</div>
<div id="Search">
Search Bar e and rest
</div>
<div id="LatestQuests">
<div id="LatestQuestsTitle"> Latest Quests </div>
<img src="Images/Imagem1.jpg" class="QuestsPromotedImages">
<img src="Images/Imagem2.jpg" class="QuestsPromotedImages"> <img src="Images/Imagem3.png" class="QuestsPromotedImages">
<img src="Images/Imagem4.png" class="QuestsPromotedImages">
<img src="Images/Imagem5.png" class="QuestsPromotedImages">
<img src="Images/Imagem6.png" class="QuestsPromotedImages">
</div>
</div>
</div>
</body>
CSS
<style>
body {
margin:0;
padding:0;
}
#MainMainBlock {
position: relative;
width: 100%;
margin-left: 0 auto;
margin-right: 0 auto;
background-color: #006;
}
#MainBlock {
display: block;
position: relative;
background-color:#FFF;
visibility: visible;
height: 1000px;
width: 980px;
margin-left: auto;
margin-right: auto;
border-top-style: outset;
border-right-style: outset;
border-bottom-style: outset;
border-left-style: outset;
border-top-color: #000;
border-right-color: #000;
border-bottom-color: #000;
border-left-color: #000;
padding: 0;
}
#Header {
visibility: visible;
height: 50px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #000;
border-right-color: #000;
border-bottom-color: #000;
border-left-color: #000;
}
#Search {
height: 35px;
background-color:#CCC;
}
#LatestQuests {
display: block;
position: relative;
width: 240px;
height: 190px;
top: 18px;
left: 18px;
border-top-style: outset;
border-right-style: outset;
border-bottom-style: outset;
border-left-style: outset;
border-top-color: #000;
border-right-color: #000;
border-bottom-color: #000;
border-left-color: #000;
}
#LatestQuestsTitle {
background: #C0C0C0;
}
.QuestsPromotedImages {
position: relative;
display: inline-block;
float: left;
width: 65px;
height: 65px;
margin-top: 12px;
margin-left: 7px;
margin-right: 7px;
}
</style>
并指出冗余;无用的 div,或者应该是目前为止的 div!
【问题讨论】:
-
有具体问题吗?或者您正在寻找代码审查?如果是这样,我建议在 Code Review 中提出这个问题。 codereview.stackexchange.com
-
哦,是的,这绝对不是问题,正在寻找一些关于如何构建某些内容(垃圾邮件 div 或其他更好、更简洁的书写方式)的提示,代码审查。
标签: html css css-tables redundancy