1

i am trying to append a new Div to a Page with Javascript , i want to have it fixed but WITHOUT overlaying the page, it should look like a sidebar at the left side of the page, currently if i set it to position fixed, it appears but overlays the whole page, any idea how to fix this?

thx in advance

4

1 回答 1

0

通过修复一个元素,您将其从正常的渲染流程中移除,因此其他元素的行为就好像它不存在一样。避免这种情况的最好方法是在页面其余部分的实际内容中添加填充,假装侧边菜单在那里。

div.menu {
position:fixed;
left:0px;
top:100px;
width:200px;
height:400px;
}
div.content {
padding-left:215px;
}

padding-left 为侧边栏填充了 200px 的框,加上 15 的很好的填充,因此文本不会压在侧面。

<div class='menu'>Menu Here</div>
<div class='content'>
    Content<br />In<br />Here<br />Fits in place
</div>
于 2012-06-22T10:55:52.657 回答