我对某些div / table有一些位置问题。
网站转储:http://www.speedyshare.com/2yyuC/Screenshot-2014-11-11-at-08.58.24.png
正如你在图片2中看到的那样,图像比其他图像低。首先,右边的菜单也是较低的(我猜这个div正在制作问题)然后我改为位置:相对于#menucontainer(菜单的div)并以这种方式将菜单放在正确的位置。但是你可以看到2个图像仍然受到#menucontainer的影响。任何想法我如何解决这个问题?
HTML:
<DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<header>
</header>
<nav>
<div id="navposition">
<div id="loggo">
<div class="loggocenter">
LodisKUNG.org
</div>
</div>
<div id="search">
<form id="searchform">
<input type="text" name="search" placeholder="Search for titles...">
<button class="submit" type="submit">Search</button>
</form>
</div>
<div id="menucontainer">
<ul>
<li id="menuhome"><a href="index.html">Home</a></li>
<li id="menuforum"><a href="index.html">Forum</a></li>
<li id="menuabout"><a href="index.html">About</a></li>
<li id="menucontact"><a href="index.html">Contact</a></li>
</ul>
</div>
</div>
</nav>
<section>
<div id="sectioncenter">
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
<div id="title">
<table>
<tr>
<th class="titlename">
The walking dead - Days gone by
</th>
</tr>
<tr>
<td class="titlepic">
<a href="#"><img src="twd.jpg" alt="twd"></a>
</td>
</tr>
</table>
</div>
</div>
</section>
</body>
</html>
CSS:
/* HTML5 CSS3 layout elements */
header {
height:30px;
background-color: #000000;
border-bottom:5px solid #c20000;
}
nav {
height:75px;
font-family: Sans-serif, Comic Sans MS;
}
section {
height:100%;
}
/* Over all CSS */
body {
margin:0px;
height:100%;
font-family: Sans-serif, Verdana;
}
/* Loggo design */
#loggo {
background-color:#c20000;
width:300px;
height:75px;
font-family: "Comic Sans MS", "Comic Sans";
font-size:35px;
color:#FFFFFF;
}
.loggocenter {
width:250px;
margin-left:auto;
margin-right:auto;
padding-top:10px;
}
/* Center section content */
#sectioncenter {
width:90%;
height:100%;
margin-left:auto;
margin-right:auto;
}
/* Center search function */
#search {
margin-left:auto;
margin-right:auto;
width:440px;
top:10px;
position:relative;
}
/* Style Navigation Menu */
#menucontainer ul {
list-style-type: none;
margin:0px;
padding:0px;
}
#menucontainer li {
display:inline;
float:left;
}
#menucontainer a {
height:100%;
width:90px;
Border-right:1px solid black;
background-color:#c20000;
display:block;
padding-left:auto;
padding-right:auto;
font-size:18px;
text-decoration:none;
text-align:center;
font-family: "Comic Sans MS", "Comic Sans";
color:#000000;
}
#menucontainer a:hover {
color:#FFFFFF;
}
#menucontainer {
float: right;
margin-bottom:1px;
position:relative;
top:-142px;
}
#navposition {
width:90%;
margin-left:auto;
margin-right:auto;
padding:0px;
height:75px;
}
#menuforum a {
background-color:green;
}
#menuabout a {
background-color:blue;
}
#menucontact a {
background-color:yellow;
}
/* Search form design */
*:focus {
outline:none;
}
#searchform input {
height:50px;
width:350px;
border-radius:5px;
font-size:20px;
font-family: "Comic Sans MS", "Comic Sans";
padding:5px;
border:3px solid black;
}
#searchform button {
font-family: "Comic Sans MS", "Comic Sans";
font-size:20px;
height:50px;
border:3px solid black;
}
/* Design looped titles */
#title {
margin-top:10px;
margin-left:5px;
float:left;
}
.titlepic img {
width:220px;
height:350px;
margin-right: auto;
margin-left: auto;
display: block;
}
#title table {
border:5px solid #f7f7f7;
border-radius:5px;
}
.titlename {
border-bottom:2px solid black;
}
很抱歉发布了整个代码,但我不确定它是否真的是菜单容器造成问题,它也可能是表格或其他东西..
感谢您的帮助!
答案 0 :(得分:1)
您需要明确浮动元素,只需在节标记
上方添加以下代码即可<div style="clear:both"></div>
它的作品!
答案 1 :(得分:0)
搜索框将元素向下推。
为nav元素指定一个高度。例如230px
您需要对元素进行一些对齐。给一些元素一个显示:块;所以彼此对齐。
我刚添加了这个:
nav,
header {
display: block;
}
section {
display: block;
float: left;
height: 100%;
width: 100%;
}