gpt4 book ai didi

html - 样式栏中的文本绝对定位为 100%

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

我的布局具有 100% 宽度的页眉栏和 100% 宽度的页脚,但内容居中且宽度仅为 800 像素。

我试图在窗口拉伸(stretch)时使文本 float 对齐到内容区域,但想不出最好的方法。

EXAMPLE

我已经尝试在标题 div 中进行绝对定位和相对定位,但是当窗口拉伸(stretch)时,我要么让文本 1 停留在同一位置,要么它在文本 1 栏中完全左对齐。

提前致谢

最佳答案

你可以试试this

您可以删除 width: 100% 作为它的 block 元素,它将占据整个宽度。

并在页眉和页脚中再添加一个 div,设置为 width: 800pxmargin: 0 auto使内部内容居中。

HTML

<div class="container">

<header> <div class="cnt">Header Text</div> </header>

<div class="content">
Div content......
</div>

<footer><div class="cnt">Footer Text</div> </footer>

</div>

CSS

.container{

height:100%;
}
header,footer{

height:50px;
border:1px solid red;
}
.cnt,
.content{
width:800px;
height:100%;
border:1px solid blue;
margin: 0 auto;
}

关于html - 样式栏中的文本绝对定位为 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24423164/

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