gpt4 book ai didi

HTML/CSS 网页看起来不正常

转载 作者:行者123 更新时间:2023-11-28 15:11:26 25 4
gpt4 key购买 nike

1) 我的 nav 和 aside 不够高。它们既不从应该开始的地方开始,也不在应该结束的地方结束。

2) 我的部分(以及导航和旁边)不在页面底部结束。

3) 我的页脚不在页面底部。

我正在使用 HTML 和 CSS。我目前正在使用谷歌浏览器。

我希望我的页面看起来像这样:

enter image description here

它看起来像这样: enter image description here

HTTP:

<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Titulazo</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<link rel="manifest" href="site.webmanifest">
<link rel="apple-touch-icon" href="icon.png">
<!-- Place favicon.ico in the root directory -->
<link rel="stylesheet" href="css/normalize.css">
<link href="style.css" rel="stylesheet">
<link rel="stylesheet" href="css/main.css">

</head>

<body>
<header id = "MainHeader">
<h1>Main Header h1</h1>
<p>Hello world! This is HTML5 Boilerplate.</p>
</header>

<nav>
<h1>Nav h1</h1>
<ul>
<li>bla</li>
<li>bla</li>
<li>bla</li>
</ul>
</nav>

<section>
<h1>Section h1</h1>
<header>
<h1>Section header</h1>
</header>

<article>
<h1>Article h1</h1>
<p>Posted on <time datetime="2009-10-22">October 22, 2009</time></p>
<p>Article text</p>
</article>

<footer>
<h1>Section Footer</h1>
</footer>
</section>

<aside>
<h1>Aside h1</h1>
<p>Aside text</p>
</aside>

<footer id = "MainFooter">
<h1>Main Footer, copyright 2018, Álvaro Puertas</h1>
</footer>


<!-- Google Analytics: change UA-XXXXX-Y to be your site's ID. -->
<script>
window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;
ga('create', 'UA-XXXXX-Y', 'auto'); ga('send', 'pageview')
</script>
<script src="https://www.google-analytics.com/analytics.js" async defer></script>
</body>

</html>

CSS:

body{
width:100%;
position:absolute;
height:auto;
}

header#MainHeader{
width: auto;
height: auto;
background-color: orange;
margin: 20px;
}

nav {
position: relative;
float: left;
height: auto;
width:200px;
margin: 20px;
top: 0px;
background-color: lightblue;
bottom: 0px;
}

section{
width: 900px;
height: auto;
float: left;
top: 500px;
background-color: pink;
}

aside{
width: 200px;
height: 100%;
margin: 20px;
top: 0px;
float: right;
background-color: lightgreen;
}

footer#MainFooter{
width: auto;
height: auto;
background-color: gray;

margin: 20px;
clear:both;
}

最佳答案

1) My nav and aside are not high enough. They dont begin where they should nor they end when they should.

  • 将 height:100% 添加到 body、nav 和 aside;从 body 中删除 position: absolute;也从 nav、section 和 aside 中删除 position: relative 因为它们是使用 float 定位的,所以最好使用边距来定位它们而不是 position relative/absolute。删除/替换 margin:20px (with margin: 0 20px) for nav and aside 使它们从相同的垂直位置开始

2) My section (and nav and aside) don't end in the bottom of the page.

  • 不要忘记清除 float 导航、部分和旁边。

3) My footer is not in the bottom of the page.

  • 将height: 100% 添加到html 标签中,并将页脚定位为absolute 或fixed,具体取决于bottom: 0 的要求,注意当溢出页脚区域时nav、section 和aside 会发生什么情况。

关于HTML/CSS 网页看起来不正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50284193/

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