Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.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 使用position:absolute(绝对)或best alternative(最佳替代)后,是否可能中断文档流?_Html_Css - Fatal编程技术网

Html 使用position:absolute(绝对)或best alternative(最佳替代)后,是否可能中断文档流?

Html 使用position:absolute(绝对)或best alternative(最佳替代)后,是否可能中断文档流?,html,css,Html,Css,我一直在努力想出一个好的解决方案来集中一个div。我不喜欢凌乱的html,我也不喜欢仅仅为了集中一些东西而有2到3个不必要的div。所以我决定使用位置:绝对 现在我知道了这个位置:绝对会破坏文档流,这就是为什么会发生这种情况,但是有没有办法“不破坏”文档流 现在,我有一个100%宽,20%高,垂直居中的div。这个div包含一个段落,我在页面底部有另一个段落元素(在这个div之外)——但是因为我使用的是position:absolute,所以版权声明出现在div之前 有没有办法让我们的文档恢复正

我一直在努力想出一个好的解决方案来集中一个div。我不喜欢凌乱的html,我也不喜欢仅仅为了集中一些东西而有2到3个不必要的div。所以我决定使用位置:绝对

现在我知道了这个位置:绝对会破坏文档流,这就是为什么会发生这种情况,但是有没有办法“不破坏”文档流

现在,我有一个100%宽,20%高,垂直居中的div。这个div包含一个段落,我在页面底部有另一个段落元素(在这个div之外)——但是因为我使用的是position:absolute,所以版权声明出现在div之前

有没有办法让我们的文档恢复正常流程。我不想求助于设置
margintop:npx
添加到页面上div后面显示的每个元素


:

HTML:


同时将版权段落设置为绝对底部

p { position: absolute; bottom: 0px; /* or any appropriate position */ }

还有别的办法吗?如果我使用此方法,我将不得不将div后面出现的所有内容设置为position:absolute,并且有很多内容。事实上,最好用一个居中的div来包装容器。position-absolute有时会遇到各种各样的麻烦。。。
*
{
    outline: none; outline: 0; border: none; border: 0; margin: 0; padding: 0;
}

#container
{
    width: 100%;
    height: 20%;

    position: absolute;
    left: 0%;
    right: 0%;
    top: 40%;
    bottom: 40%;

    background-color: khaki;
}

p
{
    text-align: center;
}
p { position: absolute; bottom: 0px; /* or any appropriate position */ }