admin管理员组文章数量:1405539
I have a section element which should be floated above the header. But should not hide the footer below. Is there a way to do it using css alone?
function App() {
return (
<div className="container">
<header>
<h1>Header</h1>
</header>
<div className="absolute-child">
Absolute child with dynamic content. .
</div>
<footer>
<h2>Footer</h2>
</footer>
</div>
);
}
The div absolute-child has dynamic content and its height can vary.
body,
html {
margin: 0;
padding: 0;
}
header {
background-color: violet;
height: 20rem;
}
.absolute-child {
background-color: aquamarine;
position: absolute;
top: 3.5rem;
width: 90%;
padding: 1rem;
height: 120vh;
}
footer {
background-color: lightcoral;
text-align: center;
padding: 1rem;
}
How to fix it with css so that the footer is not hidden when the height of the absolute-element increase?
Tried using a ghost element along with the absolute element to stretch the height but it doesnt seem to work.
I have a section element which should be floated above the header. But should not hide the footer below. Is there a way to do it using css alone?
function App() {
return (
<div className="container">
<header>
<h1>Header</h1>
</header>
<div className="absolute-child">
Absolute child with dynamic content. .
</div>
<footer>
<h2>Footer</h2>
</footer>
</div>
);
}
The div absolute-child has dynamic content and its height can vary.
body,
html {
margin: 0;
padding: 0;
}
header {
background-color: violet;
height: 20rem;
}
.absolute-child {
background-color: aquamarine;
position: absolute;
top: 3.5rem;
width: 90%;
padding: 1rem;
height: 120vh;
}
footer {
background-color: lightcoral;
text-align: center;
padding: 1rem;
}
How to fix it with css so that the footer is not hidden when the height of the absolute-element increase?
Tried using a ghost element along with the absolute element to stretch the height but it doesnt seem to work.
Share asked Mar 9 at 1:00 WebRTC NewbieWebRTC Newbie 54 bronze badges1 Answer
Reset to default 0Remove the position: abolute; top: 3.5rem;
and use translate: 0 -1.5rem;
to paint the element over the header:
body,
html {
margin: 0;
padding: 0;
}
header {
background-color: violet;
}
.absolute-child {
translate: 0 -1.5rem;
background-color: aquamarine;
width: 90%;
padding: 1rem;
height: 120vh;
}
footer {
background-color: lightcoral;
text-align: center;
padding: 1rem;
}
<div class="container">
<header>
<h1>Header</h1>
</header>
<div class="absolute-child">
Absolute child with dynamic content. .
</div>
<footer>
<h2>Footer</h2>
</footer>
</div>
本文标签: htmlStretch the height of the parent to the height of the absolute element with cssStack Overflow
版权声明:本文标题:html - Stretch the height of the parent to the height of the absolute element with css - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744881332a2630223.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论