2016-08-19 69 views
0

我希望边栏在页脚之前结束。 The line shows where the sidebar should end网站边栏CSS

第一个是边栏的CSS代码。第二个是整个页面的HTML代码。

#sidebar { 
 
    float: right; 
 
    background: #d1bdbd; 
 
    padding: 10px; 
 
    top: 65px; 
 
    bottom: 0; 
 
    right: 50px; 
 
    position: absolute; 
 
}
<div class="row" id="sidebar" style="text-align: center"> 
 
    <h3>Current Time:</h3> 
 
    <embed src=http://flash-clocks.com/free-flash-clocks-blog-topics/free-flash-clock-161.swf width=200 height=100 wmode=transparent type=application/x-shockwave-flash> 
 
    <h3>Most recent posts:</h3> 
 
    @foreach (var post in ViewBag.SidebarPosts) { 
 
    <div><a href="Posts/Details/@post.Id" class="hyperlink"> @post.Title</a> 
 
    </div> 
 
    } 
 
</div> 
 

 
@foreach (var post in Model) { 
 
<section class="row"> 
 
    <article class="post col-md-8"> 
 
    <h2 class="title"><a href="/Posts/Details/@post.Id" class="hyperlink">@post.Title</a></h2> 
 
    <div class="about"> 
 
     Posted on <i>@post.Date</i> 
 
     @if (post.Author!=null) { @: by <i>@post.Author.FullName</i> 
 
     } 
 
    </div> 
 
    <div class="body">@Html.Raw(Utils.CutText(post.Body)) @Html.ActionLink("Read more", $"Details/{post.Id}", "Posts")</div> 
 
    </article> 
 
</section> 
 
}

在此先感谢。

回答

0

您的页脚需要设置为清除:both;这将是说 © 2016年的部分...

您可以在页面模板或共享布局中找到它的实际类。如果您正在运行Firefox或Chrome,则可以检查该元素,然后将其设置为清除这两个元素。

+0

- 这不会改变任何东西。 –

0

这样做,你可以使用Flexbox的布局(css-tricks article

这是我对你的情况的解决方案:http://cssdeck.com/labs/ptuzfrep

header{background: yellow;} 
section.container{ 
    display: flex; 
} 
section.content{ 
    background: red; 
} 
section.sidebar{ 
    background: blue; 
    max-width: 300px; 
} 
footer{background: green;} 


<header>Header</header> 
<section class="container"> 
    <section class="content"> 
    content 
    </section> 
    <section class="sidebar"> 
    content 
    </section> 
</section> 
<footer>Footer</footer> 
+0

欢迎来到SO!请避免*只是*在您的答案中张贴链接。链接可能会变坏,并且可能证明您的答案在未来相关时非常重要 - 这适用于代码片段和参考文本。相反,考虑添加一些相关的代码片段来回答这个问题,以及它如何工作的简短解释(我们开发人员喜欢知道东西是如何工作的);并尽一切可能 - 包含一个供参考的链接 –