gpt4 book ai didi

html - html5 中的页脚

转载 作者:太空宇宙 更新时间:2023-11-04 05:13:11 26 4
gpt4 key购买 nike

我正在尝试创建一个横跨屏幕宽度的页脚。它嵌套在宽度为 825px 的 body 标签中(通过使用 margin left/right auto 居中),所以我将它取出并嵌套在 html 标签下,从而消除了宽度限制。

不过现在看起来是页脚元素与左下角居中的 body 标签对齐。我希望它从屏幕的最左侧开始。

我必须怎么做才能让页脚元素从左到右横跨整个屏幕宽度?

最佳答案

您不希望页脚位于 HTML 标记之外。这样的事情应该有效。

如果您在 body 标签上设置了宽度,则 100% 只会扩展到标签上设置的宽度。另外,如果您打算使用 HTML5,我建议您使用 <footer></footer>标签。请记住,HTML5 需要 hack 才能在旧版浏览器上工作。

<style type="text/css">

body {/*use this to declare font-family and other common attributes */}
#header {width:825px;height:200px;margin:0 auto 0 auto}/*or whatever your dimensions are*/
#main-content-wrapper {width:825px;margin:0 auto 0 auto;}
#footer {width:100%;}


</style>

<html>
<head>
<title></title>
<head>

<body>

<div id="header"></div>

<div id="main-content-wrapper"></div>

<div id="footer"></div>

</body>

</html>

关于html - html5 中的页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8807038/

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