Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.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在我的页面的两侧对齐,现在我希望它们之间的div在中间对齐 这是一个我想要的中间蓝色分区 HTML: <div class="lateral_div" style="float: left"></div> <div class="center_div" ></div> <div class="lateral_div" style="float: right"></div> 使用margin:0 auto作为中

我有两个div在我的页面的两侧对齐,现在我希望它们之间的div在中间对齐

这是一个我想要的中间蓝色分区

HTML:

<div class="lateral_div" style="float: left"></div>
<div class="center_div" ></div>
<div class="lateral_div" style="float: right"></div>

使用
margin:0 auto
作为中间div

使用
margin:0 auto
作为中间div

使用
margin:0 auto
作为中间div

使用
margin:0 auto
作为中间div

您需要将
文本对齐:center
添加到
主体
(或其他父元素)的中间内联元素,然后解开居中的
div
并将其显示为
display:inline块

修订CSS

body {
    text-align:center;
}
.lateral_div {
    width: 80px;
    height: 100px;
    background-color: red;
    margin: 0 10px;
}
.center_div {
    width: 200px;
    height: 160px;
    background-color: blue;
    display:inline-block;
}

您需要将
text align:center
添加到
主体
(或其他父元素)以居中内联元素,然后取消居中的
div
并将其赋予
显示:内联块

修订CSS

body {
    text-align:center;
}
.lateral_div {
    width: 80px;
    height: 100px;
    background-color: red;
    margin: 0 10px;
}
.center_div {
    width: 200px;
    height: 160px;
    background-color: blue;
    display:inline-block;
}

您需要将
text align:center
添加到
主体
(或其他父元素)以居中内联元素,然后取消居中的
div
并将其赋予
显示:内联块

修订CSS

body {
    text-align:center;
}
.lateral_div {
    width: 80px;
    height: 100px;
    background-color: red;
    margin: 0 10px;
}
.center_div {
    width: 200px;
    height: 160px;
    background-color: blue;
    display:inline-block;
}

您需要将
text align:center
添加到
主体
(或其他父元素)以居中内联元素,然后取消居中的
div
并将其赋予
显示:内联块

修订CSS

body {
    text-align:center;
}
.lateral_div {
    width: 80px;
    height: 100px;
    background-color: red;
    margin: 0 10px;
}
.center_div {
    width: 200px;
    height: 160px;
    background-color: blue;
    display:inline-block;
}

您需要将标记更改为:

<div class="lateral_div" style="float: left"></div>
<div class="lateral_div" style="float: right"></div>
<div class="center_div"></div>

演示:

您需要将标记更改为:

<div class="lateral_div" style="float: left"></div>
<div class="lateral_div" style="float: right"></div>
<div class="center_div"></div>

演示:

您需要将标记更改为:

<div class="lateral_div" style="float: left"></div>
<div class="lateral_div" style="float: right"></div>
<div class="center_div"></div>

演示:

您需要将标记更改为:

<div class="lateral_div" style="float: left"></div>
<div class="lateral_div" style="float: right"></div>
<div class="center_div"></div>

演示:

将所有div放在另一个div中,并使用css样式的属性显示:inline块;它会解决你的问题

HTML:

<div id="container">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
#container{
 width:100%;
 text-align:center;
}
#left{
 float:left;
 width:100px;
}
#right{
 float:right;
 width:100px;
}
#center{
 margin:0 auto;
 width:100px;
 display: inline-block;
}

祝你好运。

将所有div放在另一个div中,并使用css样式的属性显示:inline block;它会解决你的问题

HTML:

<div id="container">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
#container{
 width:100%;
 text-align:center;
}
#left{
 float:left;
 width:100px;
}
#right{
 float:right;
 width:100px;
}
#center{
 margin:0 auto;
 width:100px;
 display: inline-block;
}

祝你好运。

将所有div放在另一个div中,并使用css样式的属性显示:inline block;它会解决你的问题

HTML:

<div id="container">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
#container{
 width:100%;
 text-align:center;
}
#left{
 float:left;
 width:100px;
}
#right{
 float:right;
 width:100px;
}
#center{
 margin:0 auto;
 width:100px;
 display: inline-block;
}

祝你好运。

将所有div放在另一个div中,并使用css样式的属性显示:inline block;它会解决你的问题

HTML:

<div id="container">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
#container{
 width:100%;
 text-align:center;
}
#left{
 float:left;
 width:100px;
}
#right{
 float:right;
 width:100px;
}
#center{
 margin:0 auto;
 width:100px;
 display: inline-block;
}


祝您好运。

如果您在父容器上定义了宽度,但没有使其浮动,那么它应该可以工作。我已经编辑了SW4的提琴:如果您在父容器上定义了宽度,而没有使其浮动,那么它应该可以工作。我已经编辑了SW4的提琴:如果您在父容器上定义了宽度,而没有使其浮动,那么它应该可以工作。我已经编辑了SW4的提琴:如果您在父容器上定义了宽度,而没有使其浮动,那么它应该可以工作。我编辑了SW4的提琴:我的父元素中有很多div,我只想将其中一个居中。。。此代码不起作用。@Youssef-您需要在问题中提供足够的详细信息,以允许回答者考虑任何可能发生的情况,否则您只能得到问题特定内容的答案。你能添加额外的信息以便我们更好地了解情况吗?我会尝试,因为这是一个巨大的项目。我将测试您的解决方案并找出错误的来源。它现在可以工作:)我只需在之后放置一个
中心div:。。。此代码不起作用。@Youssef-您需要在问题中提供足够的详细信息,以允许回答者考虑任何可能发生的情况,否则您只能得到问题特定内容的答案。你能添加额外的信息以便我们更好地了解情况吗?我会尝试,因为这是一个巨大的项目。我将测试您的解决方案并找出错误的来源。它现在可以工作:)我只需在
之后放置一个
中心div:。。。此代码不起作用。@Youssef-您需要在问题中提供足够的详细信息,以允许回答者考虑任何可能发生的情况,否则您只能得到问题特定内容的答案。你能添加额外的信息以便我们更好地了解情况吗?我会尝试,因为这是一个巨大的项目。我将测试您的解决方案并找出错误的来源。它现在可以工作:)我只需在
之后放置一个
中心div:。。。此代码不起作用。@Youssef-您需要在问题中提供足够的详细信息,以允许回答者考虑任何可能发生的情况,否则您只能得到问题特定内容的答案。你能添加额外的信息以便我们更好地了解情况吗?我会尝试,因为这是一个巨大的项目。我将测试您的解决方案并找出错误的来源。它现在可以工作:)我只需在
之后放置一个
中心分区:就可以了。它似乎可以工作了,谢谢你。即使我不想改变我的标记。它似乎起作用了,谢谢你。即使我不想改变我的标记。它似乎起作用了,谢谢你。即使我不想改变我的标记。它似乎起作用了,谢谢你。即使我不想更改我的标记。