Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.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_Alignment_Fixed_Percentage - Fatal编程技术网

Html 对齐固定div标记百分比

Html 对齐固定div标记百分比,html,alignment,fixed,percentage,Html,Alignment,Fixed,Percentage,我有两个标记(一个是固定的,另一个是相对的,两个都是浮动的)。 我想将它们按百分比并排排列 这是一个例子 <style> #mainDiv{ width:80%; margin-left: 10%; height: 200px; } #fixedDiv{ float: left; width: 30%; background-color:red; position: fixed; height: inherit; } #

我有两个
标记(一个是固定的,另一个是相对的,两个都是浮动的)。 我想将它们按百分比并排排列

这是一个例子

<style>
#mainDiv{
    width:80%;
    margin-left: 10%;
    height: 200px;
}
#fixedDiv{
    float: left;
    width: 30%;
    background-color:red;
    position: fixed;
    height: inherit;
}
#relativeDiv{
    float: right;
    width: 70%;
    background-color:blue;
    position: relative;
    height: inherit;
}
</style>
<div id="mainDiv">
    <div id="fixedDiv">Fixed DIV</div>
    <div id="relativeDiv">Relative DIV</div>
</div>

#mainDiv{
宽度:80%;
左边距:10%;
高度:200px;
}
#固定的{
浮动:左;
宽度:30%;
背景色:红色;
位置:固定;
身高:继承;
}
#相对的{
浮动:对;
宽度:70%;
背景颜色:蓝色;
位置:相对位置;
身高:继承;
}
固定DIV
相对DIV

同样

只需将
宽度
中的
#relativeDiv
大小减小到
宽度:62%或调整它

其对齐!为什么你想说呢?第一个是30%,第二个是70%。。。但是存在重叠,您不能浮动
位置:固定的
元素。此外,当屏幕滚动时,它们将不再并排。div重叠的原因是,当您创建div位置时:fixed它将相对于主体,因此其宽度将为主体的30%,而不是包含div的30%