javascript - 如何将 div 放在页眉 div 下方和页脚 div 上方,全高 html
问题描述
我是新手reactjs
。我有一个页面,其中3
包含divs
.
这是 我的页面
这是我尝试过的代码:
return (
<div >
{/* First Block */}
<div style={{ padding: "0.8%", backgroundColor:"red" }}>
Block 1
</div>
{/* Second Block */}
<div style={{ height: "40%", overflowY: 'scroll', backgroundColor: "aqua", position: "fixed", width: "100%" }} >
Block 2
</div>
{/* Third Block */}
<div style={{ display: "flex", position: "fixed", bottom: 0, right: 0, left: 0, height: "40px", backgroundColor: "grey", }}>
Block3
</div>
</div>
);
Block 1
是一个标题块。Block 2
是内容块。Block 3
是页脚块。.我固定Block 1
在顶部和Block 3
底部。现在我希望我的 Block 2 能以全高安装在中间。我可以手动为 Block 2 提供高度。但是那里有很多屏幕尺寸。对我来说,这变成了一个混乱的过程。我想让 Block 2 适合所有屏幕尺寸。我怎样才能做到这一点。我搜索了 Stackoverflow,但我无法修复它。请帮我解决一些问题。
我需要的输出: 输出屏幕
解决方案
尝试这个。页眉和页脚将被修复。只有中心内容可以滚动
<div style={{ display:"flex", backgroundColor: "green", height: "100vh" , flexDirection:"column", flex:1}}>
{/* First Block */}
<div style={{backgroundColor:"red", width: "100%"}}>
Block 1
</div>
{/* Second Block */}
<div style= {{background: "pink",display:"block", overflow: "auto", flex:1}}>
Block 2
An essay is, generally, a piece of writing that gives the author's own argument, but the definition is vague, overlapping with those of a letter, a paper, an article, a pamphlet, and a short story. Essays have traditionally been sub-classified as formal and informal. Formal essays are characterized by "serious purpose, dignity, logical organization, length," whereas the informal essay is characterized by "the personal element (self-revelation, individual tastes and experiences, confidential manner), humor, graceful style, rambling structure, unconventionality or novelty of theme," etc.[1]
Essays are commonly used as literary criticism, political manifestos, learned arguments, observations of daily life, recollections, and reflections of the author. Almost all modern essays are written in prose, but works in verse have been dubbed essays (e.g., Alexander Pope's An Essay on Criticism and An Essay on Man). While brevity usually defines an essay, voluminous works like John Locke's An Essay Concerning Human Understanding and Thomas Malthus's An Essay on the Principle of Population are counterexamples.
In some countries (e.g., the United States and Canada), essays have become a major part of formal education. Secondary students are taught structured essay formats to improve their writing skills; admission essays are often used by universities in selecting applicants, and in the humanities and social sciences essays are often used as a way of assessing the performance of students during final exams.
The concept of an "essay" has been extended to other media beyond writing. A film essay is a movie that often incorporates documentary filmmaking styles and focuses more on the evolution of a theme or idea. A photographic essay covers a topic with a linked series of photographs that may have accompanying text or captions
An essay is, generally, a piece of writing that gives the author's own argument, but the definition is vague, overlapping with those of a letter, a paper, an article, a pamphlet, and a short story. Essays have traditionally been sub-classified as formal and informal. Formal essays are characterized by "serious purpose, dignity, logical organization, length," whereas the informal essay is characterized by "the personal element (self-revelation, individual tastes and experiences, confidential manner), humor, graceful style, rambling structure, unconventionality or novelty of theme," etc.[1]
Essays are commonly used as literary criticism, political manifestos, learned arguments, observations of daily life, recollections, and reflections of the author. Almost all modern essays are written in prose, but works in verse have been dubbed essays (e.g., Alexander Pope's An Essay on Criticism and An Essay on Man). While brevity usually defines an essay, voluminous works like John Locke's An Essay Concerning Human Understanding and Thomas Malthus's An Essay on the Principle of Population are counterexamples.
In some countries (e.g., the United States and Canada), essays have become a major part of formal education. Secondary students are taught structured essay formats to improve their writing skills; admission essays are often used by universities in selecting applicants, and in the humanities and social sciences essays are often used as a way of assessing the performance of students during final exams.
The concept of an "essay" has been extended to other media beyond writing. A film essay is a movie that often incorporates documentary filmmaking styles and focuses more on the evolution of a theme or idea. A photographic essay covers a topic with a linked series of photographs that may have accompanying text or captions
An essay is, generally, a piece of writing that gives the author's own argument, but the definition is vague, overlapping with those of a letter, a paper, an article, a pamphlet, and a short story. Essays have traditionally been sub-classified as formal and informal. Formal essays are characterized by "serious purpose, dignity, logical organization, length," whereas the informal essay is characterized by "the personal element (self-revelation, individual tastes and experiences, confidential manner), humor, graceful style, rambling structure, unconventionality or novelty of theme," etc.[1]
</div>
{/* Third Block */}
<div style = {{marginTop:"auto", backgroundColor:"grey"}}>
Block3
</div>
</div>
推荐阅读
- javascript - Express 路由问题 - POST 404(未找到)
- linux - 无法在 debian 服务器上使用 username@hostname 连接打开的 ssl 密钥
- angular - 当 karma-jasmine 给出 `WARN:` 消息时,我如何追踪导致它们的规范文件或组件?
- javascript - 保存时无法保持复选框选中
- regex - 我需要帮助构建正则表达式
- javascript - SnekFetch reddit 发布 nsfw 标签?
- inheritance - draw uml class diagram with both super class object and subclass object being called in a third class
- python-3.x - 将 Tkinter 输入框映射到 python 3.8 中的变量
- android - 为什么 Android Studio 无法读取我解压后的 docx xml 文件的全部内容?
- sql - 根据组合框值在文本框中显示多个值