gpt4 book ai didi

html - CSS div/元素位置问题

转载 作者:太空宇宙 更新时间:2023-11-04 12:41:04 25 4
gpt4 key购买 nike

我的某些 div/表格存在位置问题。

网站转储:http://www.speedyshare.com/2yyuC/Screenshot-2014-11-11-at-08.58.24.png

正如您在图 2 中看到的,图像比其余图像低。起初,右边的菜单也较低(我猜这个 div 是问题所在),但后来我更改为 position:relativ for #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;
}

很抱歉发布了整个代码,但我不确定是否真的是菜单容器导致了问题,它也可能是表格或其他东西..

感谢您的帮助!

最佳答案

你需要元素的清晰 float ,只需在 section 标签上方添加以下代码

<div style="clear:both"></div>

它的作品!

关于html - CSS div/元素位置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26860313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com