Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.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为父级的100%高度,并将图像置于其中间_Html_Css - Fatal编程技术网

html强制div为父级的100%高度,并将图像置于其中间

html强制div为父级的100%高度,并将图像置于其中间,html,css,Html,Css,我搜索了又搜索,尝试了不同的技术,但没有任何效果 我有3列,在左列和右列中,我有一个图像需要垂直对齐到中心,也需要水平对齐到中心。然而,我的中间内容部分有点向下延伸。因此,我希望我的2列与高度匹配。这3列被包装在另一个div中 有什么想法吗?我不确定你说的“100%的高度”是什么意思,这应该无关紧要,但我只想使用css的“边距”属性,并根据父级大小为其指定百分比(而不是像素)。这可能不是你想要的,但它在网站上保存了我的屁股,这可能是最简单的方法 将此添加到css中: margin: auto;

我搜索了又搜索,尝试了不同的技术,但没有任何效果

我有3列,在左列和右列中,我有一个图像需要垂直对齐到中心,也需要水平对齐到中心。然而,我的中间内容部分有点向下延伸。因此,我希望我的2列与高度匹配。这3列被包装在另一个div中


有什么想法吗?

我不确定你说的“100%的高度”是什么意思,这应该无关紧要,但我只想使用css的“边距”属性,并根据父级大小为其指定百分比(而不是像素)。这可能不是你想要的,但它在网站上保存了我的屁股,这可能是最简单的方法

将此添加到css中:

margin: auto;
padding: auto

在您的情况下,最好使用table而不是div,因为某些行中某些单元格的任何更改都会影响其他单元格。。试试这段代码,它可以完成这项工作

<div style="border:1px black solid; width:850px; margin:auto">
  <table style="border:1px red solid; width:100%; height:500px; text-align:center" cellspacing="0">
    <tr>
      <td style="border:1px lime solid">1</td>
      <td style="border:1px lime solid">2</td>
      <td style="border:1px lime solid">3</td>
    </tr>
  </table>
</div>

1.
2.
3.

请提供您尝试过的代码,如果可能,请提供屏幕截图!使用语义标记(好)和CSS表格布局代替表格布局(坏),例如
display:table
display:table cell
。进一步:。