Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在页眉和页脚div之间垂直对齐div左、中、右_Html_Css - Fatal编程技术网

Html 如何在页眉和页脚div之间垂直对齐div左、中、右

Html 如何在页眉和页脚div之间垂直对齐div左、中、右,html,css,Html,Css,我是编程新手,我想将div元素安排如下: header div 1 -------------------- left 2 | center 3| right 4 | --------------------- footer div 5 我尝试了位置和显示属性,但没有得到想要的结果 如何以这种方式排列以及如何以简单的方式排列任何div元素?请针对您的div结构尝试以下代码 .wrapper{ 颜色:#fff; 浮动:左; 文本对齐:居中; 宽度:100%; } .标题{ 背景色:红色; 浮

我是编程新手,我想将div元素安排如下:

header div 1
--------------------
left 2 | center 3| right 4 |
---------------------
footer div  5
我尝试了位置和显示属性,但没有得到想要的结果


如何以这种方式排列以及如何以简单的方式排列任何div元素?

请针对您的div结构尝试以下代码

.wrapper{
颜色:#fff;
浮动:左;
文本对齐:居中;
宽度:100%;
}
.标题{
背景色:红色;
浮动:左;
宽度:100%;
}
.左{
背景颜色:橙色;
浮动:左;
宽度:25%;
}
.中心{
背景颜色:绿色;
浮动:左;
宽度:50%;
}
.对{
背景颜色:橙色;
浮动:左;
宽度:25%;
}
.页脚{
背景颜色:蓝色;
浮动:左;
宽度:100%;
}
.页眉,.页脚{
利润率:1%0;
}

标题Div
左Div
中心分区
右分区
页脚分区
试试这段代码

HTML

代码笔链接


希望您至少尝试自己编写代码。堆栈溢出不是代码编写服务。我建议你做一些,或者通过谷歌,或者通过搜索,尝试一下。如果您仍然有问题,请带着您的代码回来,并解释您尝试了什么以及为什么它不起作用。
<div class="header">Header Div</div>

<div class="left-section"></div>
<div class="center-section"></div>
<div class="right-section"></div>


<div class="footer-section">Footer</div>
.header{
    width:100%;
    height:50px;
    background:green;
}
.left-section{
    height:500px;
    width:29%;
    display:inline-block;
    background:yellow;
   padding:0px;
    margin:0px;
}
.right-section{
    height:500px;
    width:29%;
    display:inline-block;
    background:gold;
   padding:0px;
    margin:0px;
}
.center-section{
    height:500px;
    width:40%;
    display:block;
    display:inline-block;
    background:gray;
    padding:0px;
    margin:0px;
}
.footer-section{
    width:100%;
    height:50px;
    background:orange;  
}