html - 侧边栏被页脚截断

标签 html css footer sidebar

我在自己的网站上工作,它仍然非常非常业余,但我遇到了一个我自己似乎无法解决的问题。

我刚刚添加了一个带有内容的边栏(没有什么特别的,只是一些填充文本),但是页脚切断了我的边栏的文本,而不是主要内容的文本。

这是我的 HTML:

<div id="content">
    <div id="main">
        <h1>PHP</h1>
    </div>
    <div id="sidebar">
        <h2>Sidebar</h2>

        <p>
        Hello, this is just some filler tekst. Blablabla blabl blabla blabla blblbla blablalbabla blablalbl.<br>
        <br>
        As you can see, it's positioned well.
        </p>
    </div>
</div>

<div id="footer">
<p>Made by me 2014</p>
</div>

这是我的 CSS:

#content {
background          :   linear-gradient(#669900, #66FF99); /* Gradient -                        Standaard */
background          :   -moz-linear-gradient(#669900, #66FF99); /* Gradient  - Firefox */
background-repeat   :   no-repeat;
background-attachment:  fixed;
/*margin-left       :   185.5px;
  margin-right      :   185.5px;*/
margin              :   0 auto;
width               :   980px;
position            :   relative;
padding             :   20px 0 25px 0;
border-left         :   5px solid lightgreen;
border-right        :   5px solid lightgreen;
}

#main {
padding             :   0 30px 0 30px;
margin-right        :   200px;
}

#sidebar {
position            :   absolute;
top                 :   0;
bottom              :   0;
left                :   780px;
width               :   180px;
float               :   right;
margin              :   0 10px 0 10px;
overflow            :   auto;
}

#sidebar h2 {
text-align          :   center;
margin-left         :   -15px;
}

抱歉,我知道要阅读的内容很多,但我希望您能有所帮助。

我的问题是:页脚不随侧边栏中的文本一起移动,它会将其切断,但当主 div 中添加文本时它会移动。

有人能帮忙吗?

最大

最佳答案

同样的问题,但是在将位置从绝对位置更改为相对位置时,侧边栏移动到帖子下方

.sidebar-wrapper {
  width: 300px;
  position: absolute;
  right: 0px;
  margin: 25px 0;
  padding: 0 20px;
  border: medium none;
  top: 0;
  bottom: 0;
  display: block;
}

关于html - 侧边栏被页脚截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22856944/

相关文章:

html - 如何使用 CSS 进行多次中断?

css - 在 Bootstrap 中对齐媒体对象,以便在图像周围交换文本

css - 调整窗口大小时,页脚背景图案被截断

html - CSS 多个多列 div

html - 如何使页脚成为文本区域

html - 实现返回顶部按钮时页脚消失

javascript - 在 jQuery 中切换类时遇到问题

css - 两个方向的DIV紧凑排列

javascript - 无法滚动查看旧输入

css - 通过选中的选择器隐藏前一个元素