gpt4 book ai didi

asp.net - 查看编辑 : CSS3 Footer sticks to bottom of the page and left column stretches to the footer

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

经过将近六个小时的反复试验,我无法为我的问题找到解决方案 - 我以前构建过这个,但无法访问旧文件来查看我做了什么,并且一直从事不同的职业多年来的道路,不幸的是我的技能已经退色了一点。

我正在建立一个网站来记录我在海上工作的时间,它将包含:- 一个 150 像素高和 100% 宽的标题- 一个 30 像素高和 100% 宽的导航栏- 宽度为 250 像素并在导航栏和页脚之间完全延伸的旁边,无论其中的内容有多少- 一个文章 div,位于旁边的右侧,根据视口(viewport)的宽度填充剩余空间- 如果内容未填满视口(viewport),或者如果文本超出视口(viewport)限制,则页脚至少位于页面底部,它将低于该范围。我不想要“始终可见”的页脚。

我正在使用 HTML5 和 CSS3 以及 ASP.net 4.5。

我目前的页眉、导航和文章都按照我想要的方式工作。但是,我不确定如何处理旁边和页脚。

我希望页脚位于页面底部。显然,如果我的页面上没有太多文字,它就会在浏览器屏幕的中间,而且众所周知,这看起来很业余而且很可笑。所以我希望它像普通网页一样位于屏幕底部。当我这样做的时候,我也希望我的旁边填充浏览器窗口左侧的 250px 宽 strip ,无论其中有多少内容,一直到页脚,这样它看起来更完整。

现在,正如我所指出的,在过去的六个小时里,我一直在加类加点,并在这方面取得了一些重大进展,但这两个问题我似乎无法解决。我已经使用这个论坛寻求帮助,并且几乎用尽了一切都没有成功。知道我以前在短短几分钟内做过很多次,但现在是凌晨 4 点,这让我很沮丧。

这是 CSS:

    * 
{
margin: 0;
}
body
{
margin: 0px auto;
height: 100%;
}

form, html
{
height: 100%;
}

header
{
margin: 0px auto;
background-color: #1041a2;
background-image: url(../Images/headerHCJ.png);
background-repeat: no-repeat;
background-position-x: right;
height: 150px;
position: relative;
}

#logo
{
margin: 0px auto;
float: left;
height: 150px;
width: 150px;
background-image: url(../Images/usmmSeal130.png);
background-repeat: no-repeat;
background-position: center;
}

#title
{
margin: 0px auto;
color: white;
position: absolute;
bottom: 45px;
padding-left: 150px;
}

#title h1
{
margin: 0px auto;
font-family: Arial;
text-shadow: 5px 5px 5px black;
}

#title h2
{
margin: 0px auto;
font-family: Arial;
text-shadow: 5px 5px 5px black;
}

nav
{
background-image: url(../Images/nav.png);
font-family: Arial;
color: white;
background-repeat: repeat-x;
height: 30px;
width: 100%;
line-height: 30px;
margin: 0px auto;

}

#content
{
margin: 0px auto;
height: 100%;
}

aside
{
margin: 180px 0px 80px 0px auto;
float: left;
width: 250px;
background-color: gray;
height: 100%;
}

article
{
margin: 0px auto;
padding-left: 250px;
min-height: 100%;
}

footer {
height:80px;
background: black;
clear: both;
}

这是我的 HTML

<body>
<form id="form1" runat="server">
<header>
<div id="logo">
</div>
<div id="title">

</div>
</header>
<nav>

</nav>
<div id="content">
<aside>
Vessel data
</aside>
<article>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</article>
</div>
<footer>

</footer>
</form>
</body>

非常感谢大家的反馈。

编辑:我非常接近解决方案。我修改了我的代码,使 aside 和 article 包含在一个 div 中,并在对 form、html 和 body 元素进行更改后将 aside 的最小高度设置为 100%。它现在扩展到 100% 的视口(viewport),但有一个问题。它实际上是视口(viewport)高度的 100%,而不是容器 div 高度的 100%。页眉/导航栏在页面顶部占据 180px,页脚在底部占据 80px。无论视口(viewport)大小如何,页面都会滚动 240 像素。我最初的解决方法是添加边距:180px 0px 80px 0px auto。然而,这并没有解决问题。编辑上面的代码以反射(reflect)更改。

最佳答案

我创建了这个 jsfiddle .

灵感来自这个article在 css-tricks.com 上。

基本概念(HTML)

<div class="content">
Content
</div>
<footer>
I'm a footer
</footer>

CSS

html, body {
height: 100%;
}
#content {
min-height: 100%;
/* equal to footer height */
margin-bottom: -80px;
}
#content:after {
content: "";
display: block;
}
footer, #content:after {
/* .push must be the same height as footer */
height: 80px;
}
footer {
background: black;
}

对于jsFiddle本身的容器,我把

display: inline-block;

对于左边类的 aside 元素,我放了

float: left;

并保留带有正确类的 article 元素,因此它可以扩展宽度。我还为它们提供了以像素为单位的最小高度属性,而不是百分比,这样您可以在视觉上看得更清楚。

关于asp.net - 查看编辑 : CSS3 Footer sticks to bottom of the page and left column stretches to the footer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23719605/

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