gpt4 book ai didi

html - 网站上的 Div 导致滚动

转载 作者:太空宇宙 更新时间:2023-11-04 10:52:02 24 4
gpt4 key购买 nike

目前我正在尝试模仿这个网站来进行一些练习 Link

但是我在网站布局方面遇到了重大问题。看来我经常使用 position: relative; 这导致我的网站搞砸了导航栏等。我不确定是否有更简单的方法是?正如您在网站上看到的那样。 Logo 和导航栏已向左右浮动,但位于屏幕中间。这是我无法解决的另一个问题。当我把我的漂浮到右边和左边时,它一直到边界。这就是为什么我使用 position 属性将它放在中间的原因。

另一个大问题是该站点不应向右滚动,但您可以向右转到我的页面。首页应该都在屏幕上,没有滚动。我再次相信这取决于 Div 结构

目前我已经设置了背景图像。两个导航栏。一个在顶部,一个在底部。我已经放入了两个日志,并放入了导航栏。但是如上所述,div 出现了问题。

HTML: 
<body>
<div class="container"></div>

<ul class="nav">
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/Member/">member</a></li>
</ul>

<div class="container1">
<p>a</p>
<div class="botLay">

</div>
</div>

<div class="logo">
<img src="Image/Logo.png">
</div>

<div class="logo1">
<img src="Image/Logo.png">
</div>
</body>

Nav div 是顶部的黑色条。容器1是底杆。 Logo 1 和 2 是两个 Logo 。

CSS:

html { 
background: url(../Image/BackgroundImage.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

html, body {
height: 100%;
}


.logo{
position: relative;
top: -157px;
left: 450px;
width: 100px;
}
.logo1{
position: relative;
top: 521px;
left: 450px;
}
.container1{
position: relative;
top: 446px;
right: 40px;
background-color: rgba(0, 0, 0, 0.65);
border-top: 0px solid rgba(0, 0, 0, 0.5);
border-bottom: 0px solid rgba(0, 0, 0, 0.5);
width: 2000px;
padding:15px;

}
.nav{
position: relative;
top: 36px;
right: 40px;
background-color: rgba(0, 0, 0, 0.65);
border-top: 0px solid rgba(0, 0, 0, 0.5);
border-bottom: 0px solid rgba(0, 0, 0, 0.5);
list-style:none;
text-align:center;
width: 2000px;
}
.nav li {
display: inline-block;
position: relative;
left: 280px;
}
.nav li + li:before {
content: "";
display: inline-block;
vertical-align: middle;
border-left: 1px solid #ffffff;
padding-left: 8px;
height: 28px;
}
.nav a{
display:inline-block;
padding:35px;
text-decoration: none;
color: white;
font: normal normal normal 12px/1.3em 'Open Sans',sans-serif;
text-transform: uppercase;
}
ul a:hover {
color: #ffcb80;
}

任何有关修复此代码的帮助和建议都将得到极大的帮助。谢谢

最佳答案

这是一个简单的解决方案

html, body {
height: 100%;
}

body {
background: url('http://www.motionbackgroundsforfree.com/wp-content/uploads/2012/02/Screen-shot-2012-02-07-at-10.02.45-AM.png') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

header > .logo{
float: left;
margin-left: 20&
}


header nav {
float: right;
}

header {
background-color: rgba(0, 0, 0, 0.65);
border-top: 0px solid rgba(0, 0, 0, 0.5);
border-bottom: 0px solid rgba(0, 0, 0, 0.5);
width: 100%;
height: 100px;
}

.nav {
margin-right: 20%;
}

.nav li {
display: inline-block;
position: relative;

}
.nav li + li:before {
content: "";
display: inline-block;
vertical-align: middle;
border-left: 1px solid #ffffff;
padding-left: 8px;
height: 28px;
}
.nav a{
display:inline-block;
padding:28px;
text-decoration: none;
color: white;
font: normal normal normal 12px/1.3em 'Open Sans',sans-serif;
text-transform: uppercase;
}
ul a:hover {
color: #ffcb80;
}


footer > .logo{
float: left;
margin-left: 200px
}



footer {
background-color: rgba(0, 0, 0, 0.65);
border-top: 0px solid rgba(0, 0, 0, 0.5);
border-bottom: 0px solid rgba(0, 0, 0, 0.5);
width: 100%;
height: 100px;
position: absolute
bottom: 0
}
<header>
<div class="logo">
<img src="http://placehold.it/140x100">
</div>
<nav>
<ul class="nav">
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/Member/">member</a></li>
</ul>
</nav>

</header>

<section>

<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</section>

<footer>
<div class="logo">
<img src="http://placehold.it/140x100">
</div>


</footer>

考虑添加响应式导航菜单 http://codepen.io/marti1125/pen/YwYOxw

关于html - 网站上的 Div 导致滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34927566/

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