gpt4 book ai didi

HTML -> 固定顶部、固定底部和动态内容

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

我想创建一个页面,其中:

1) 顶部,100px,固定2)底部,100px,固定3) 顶部和底部之间有动态内容

我能够准确地创建那个,但我有一个问题,当我滚动动态内容时,元素在顶部和底部下方和上方移动,并且相同的元素通过固定的顶部/底部可见。

我试过 clear: both;在顶部和底部的 div 上,但由于它们是固定的,因此清晰:两者;没用。

我想将动态元素保留在顶部和底部之间的内容 div 中,如果可能,仍然使用主文档滚动条在其中滚动。

这里有一个例子,假设线条代表顶部和底部的固定div,'元素'是动态内容。

元素 - 不正确


元素 - 不正确


元素

元素

元素

元素

元素


元素 - 不正确


元素 - 不正确

希望我已经足够清楚并提前致谢!

最佳答案

我想这就是您要找的。

查看此 fiddle .

HTML

<header>
This is the header!
</header>
<article>
<p>Goodness one unimaginative rooster some that circa much jay goodness gosh pessimistic scantly dark some modest gasped where unexplainable some before about that a hello firefly macaw ethereally indecisive panda lorikeet where a peskily jellyfish a since lied factiously in and that after but falteringly so worm flabbily yet hey gladly more versus much precarious because a the boisterous quiet fed one alas hawk flawlessly thanks some.</p>
<p>Squirrel much krill regarding before contrary jeez outdid warthog immaturely articulately valiant hey suggestive thus far won darn wow scorpion portentously more hotly miraculous jeepers meagerly since excluding that however pinched yet whale adoringly floppy tenably wow and after via for unproductively as one prior the more on urchin rang much because some more approving near oh a as far lion some lucky far much frog far and beneath underlay far after nosy jaguar subconscious after this far input frequently distant the much positively gagged jeez unobtrusively far sank less before babbled far by when this the this sensible outside.</p>
<p>That far qualitatively intrepid vulture a ferret disgraceful moaned therefore easy much and curt insincerely dachshund notwithstanding yikes and dragonfly and patted until much jeez close fumed divisive copiously wherever near near far perceptible shrewdly ground yikes opened as elaborate adversely spilled that creepy imaginative by in hello groundhog magnificently jeez hence crud versus desperately caterpillar checked one wicked far some yikes.</p>
<p>And darn dependent that urchin upon much jeez ably sniffed a less in far darn far incorrect between inept caterpillar man-of-war manta hence ironically into more amenable negative sanctimoniously tortoise eagle far spoiled clapped tepid yikes irresistibly testy warthog hugged immense much immense alas thus paid therefore agitatedly about well following the hey aboard and that after and condescending seagull because alas slept hey this went dove far much far considering raccoon witless under ungraceful.</p>
<p>Emptied much gosh circuitously inside along a far pointed fanatic hey bravely with far yikes capybara meadowlark sedulous some lion squid floated darn drolly underwrote loving spat maliciously coaxing unwilling goodness seagull elephant snickered balked sloth for kookaburra inside untactfully so the where much human then because pungently cracked heard overtook firm skeptically reverently much some jeez less and hey towards.</p>
</article>
<footer>
This is the footer!
</footer>

CSS

body {
font-family: sans-serif;
}

header, footer {
position: fixed;
height: 100px;
text-align: center;
width: 100%;
background: #ff0450;
color: #fff;
text-transform: uppercase;
line-height: 6em;
}

header {
top: 0;
}

footer {
bottom: 0;
}

article {
margin: 100px 50px 0;
}

article p {
margin: 20px 0;
}

article p:first-line {
font-variant: small-caps;
}

更新

body {
font-family: sans-serif;
}

header, footer {
position: fixed;
height: 100px;
text-align: center;
width: 100%;
background: #ff0450;
color: #fff;
text-transform: uppercase;
line-height: 6em;
}

header:before {
content: "";
position: absolute;
height: 20px;
background: #fff;
z-index: 999;
top: -20px;
width: 100%;
left: 0;
}

footer:before {
content: "";
position: absolute;
height: 20px;
background: #fff;
z-index: 999;
bottom: -20px;
width: 100%;
left: 0;
}

header {
top: 0;
margin-top: 20px;
}

footer {
bottom: 0;
margin-bottom: 20px;
}

article {
margin: 120px 50px 0;
}

article p {
margin: 20px 0;
}

article p:first-line {
font-variant: small-caps;
}

更新了 fiddle也是。

关于HTML -> 固定顶部、固定底部和动态内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8116964/

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