gpt4 book ai didi

html - 调整窗口大小时,div 移动到其他 div 下面

转载 作者:行者123 更新时间:2023-11-28 08:28:00 27 4
gpt4 key购买 nike

我是网络开发新手,需要一些帮助来解决这个简单的问题。调整大小时,菜单项会移动到名称下方,有人能告诉我哪里搞砸了吗?

我一直在阅读其他一些解决方案并了解想法,但就是找不到我的错误。

> 
<!doctype html>
<html>
<head>
<title>About</title>

<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<style type="text/css">

* {
font-family: Lucida Sans Unicode, Lucida Grande, sans-serif;
}



body {
background-color: #FAFAFA;
color: #2E2E2E;

}

#topmenu {
float: right;
padding-top: 10px;
position: relative;

}

#topmenu ul {
list-style:none;
width: auto;


}

#topmenu li {
float:left;
padding: 5px 10px 0px 20px;
margin-right: 20px;
border-right: 1px solid #47008F;
text-decoration: underline;

}

a:hover {

font-size: 20px;
}

a:link {
color: #47008F;
}


#name {
margin-bottom: 10px;
padding-left: 20px;
color: #47008F;
display:inline-block;

}

#topcontainer {
width: 100%;
background-color: #A4A4A4;
height: 60px;
margin-bottom: 5px;
font-family: Lucida Grande;
margin-right: 50px;
border-radius: 25px;
float: left;

}

#break {
background-color:#47008F;
height: 1px;
margin-bottom:5px;
clear: both;
}

#midcontainer {

clear:both
padding-left: 50px

}

#midcontainer img {
position: relative;
height:300px;
padding: 20px 200px 50px 200px;
float: left;
padding-right:50px;
}

#bio {
padding-top: 75px;
position: relative;
}


</style>


</head>

<body>

<div id="topcontainer">




<h1 id="name">Robert</h1>

<div id="topmenu">

<ul>
<li><a href="PersonalPage.html">About</a></li>
<li><a href="PersonalPageResume.html">Resume</a></li>
<li><a href="PersonalPagePortfolio.html">Portfolio</a></li>
<li><a href="PersonalPageContact.html">Contact</a></li>
</ul>

</div>

</div>


<div id="break"></div>
</div>



<div id="midcontainer">

<img src="images/me.jpg"/>

<div id="bio">

<p>
<h3> Text goes here.............</h3>
<p>
something
</p>

</p>

</div>

</div>

</body>
</html>

最佳答案

我已经评论了顶部容器的“高度”,并删除了一个不需要的结束 div 标签。它适用于 Chrome。

<!doctype html>
<html>
<head>
<title>About</title>

<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<style type="text/css">

* {
font-family: Lucida Sans Unicode, Lucida Grande, sans-serif;
}


body {
background-color: #FAFAFA;
color: #2E2E2E;

}

#topmenu {
float: right;
padding-top: 10px;
position: relative;

}

#topmenu ul {
list-style:none;
width: auto;


}

#topmenu li {
float:left;
padding: 5px 10px 0px 20px;
margin-right: 20px;
border-right: 1px solid #47008F;
text-decoration: underline;

}

a:hover {

font-size: 20px;
}

a:link {
color: #47008F;
}


#name {
margin-bottom: 10px;
padding-left: 20px;
color: #47008F;
display:inline-block;

}

#topcontainer {
width: 100%;
background-color: #A4A4A4;
/*height: 60px;*/
margin-bottom: 5px;
font-family: Lucida Grande;
margin-right: 50px;
border-radius: 25px;
float: left;

}

#break {
background-color:#47008F;
height: 1px;
margin-bottom:5px;
clear: both;
}

#midcontainer {

clear:both
padding-left: 50px

}

#midcontainer img {
position: relative;
height:300px;
padding: 20px 200px 50px 200px;
float: left;
padding-right:50px;
}

#bio {
padding-top: 75px;
position: relative;
}


</style>


</head>

<body>

<div id="topcontainer">
<h1 id="name">Robert</h1>
<div id="topmenu">
<ul>
<li><a href="PersonalPage.html">About</a></li>
<li><a href="PersonalPageResume.html">Resume</a></li>
<li><a href="PersonalPagePortfolio.html">Portfolio</a></li>
<li><a href="PersonalPageContact.html">Contact</a></li>
</ul>

</div>
<div id="break"></div>
</div>

<div id="midcontainer">

<img src="images/me.jpg" />

<div id="bio">

<p>
<h3>Text goes here.............</h3>
<p>
something
</p>

</p>

</div>

</div>

</body>
</html>

关于html - 调整窗口大小时,div 移动到其他 div 下面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28446682/

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