Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.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中的内容会破坏垂直对齐_Html_Css - Fatal编程技术网

Html 为什么这个Div中的内容会破坏垂直对齐

Html 为什么这个Div中的内容会破坏垂直对齐,html,css,Html,Css,你可以在这里看到这个 如果要修复它,请使用垂直对齐 .outer { width: 100px; height: 100px; background-color: green; display: inline-block; position: relative; vertical-align: top; } 或者,您可以使用“内联表”进行显示,以获得相同的结果 .outer { width: 100px; height: 100px; background

你可以在这里看到这个


如果要修复它,请使用垂直对齐

.outer {
  width: 100px;
  height: 100px;
  background-color: green;
  display: inline-block;
  position: relative;
  vertical-align: top;
}
或者,您可以使用“内联表”进行显示,以获得相同的结果

.outer {
  width: 100px;
  height: 100px;
  background-color: green;
  display: inline-table;
  position: relative;
}

如果要修复它,请使用垂直对齐

.outer {
  width: 100px;
  height: 100px;
  background-color: green;
  display: inline-block;
  position: relative;
  vertical-align: top;
}
或者,您可以使用“内联表”进行显示,以获得相同的结果

.outer {
  width: 100px;
  height: 100px;
  background-color: green;
  display: inline-table;
  position: relative;
}

您可以为外部Div提供垂直对齐

"vertical-align: top; OR  vertical-align: bottom;"

.outer {
    width: 100px;
    height: 100px;
    background-color: green;
    display:inline-block;
    position: relative;
    vertical-align: top;
}
或者,您可以将“显示:内联块;”更改为“
”浮动:左;”


希望这有帮助

您可以为外部Div提供垂直对齐

"vertical-align: top; OR  vertical-align: bottom;"

.outer {
    width: 100px;
    height: 100px;
    background-color: green;
    display:inline-block;
    position: relative;
    vertical-align: top;
}
或者,您可以将“显示:内联块;”更改为“
”浮动:左;”


希望这有帮助

垂直对齐是您在@ek_ny缺少的属性。但是相对位置是不必要的。他需要“相对位置”作为他的“内部”div,它使用绝对定位。啊,是的。。谢谢Yosep。垂直对齐是您在@ek_ny缺少的属性。但是相对位置是不必要的。他需要“相对位置”作为他的“内部”div,它使用绝对定位。啊,是的。。谢谢你,约瑟普。