简体   繁体   English

网站侧边栏CSS

[英]Website sidebar CSS

I want the sidebar to end just before the footer. 我希望边栏在页脚之前结束。 The line shows where the sidebar should end 该行显示侧边栏应在何处结束

The first one is the CSS code of the sidebar. 第一个是侧边栏的CSS代码。 The second one is the HTML code of the whole page. 第二个是整个页面的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> } 

Thanks in advance. 提前致谢。

your footer needs to be set to clear:both; 您的页脚需要清除: that would be the section that says © 2016... 那就是说©2016 ...

You may find its actual class in a page template or in the shared layout. 您可以在页面模板或共享布局中找到其实际类。 If you are running firefox or chrome you can inspect the element and then set it to clear both. 如果您运行的是Firefox或chrome,则可以检查该元素,然后将其设置为同时清除两者。

to do that you can use the flexbox layout ( css-tricks article ) 为此,您可以使用flexbox布局( css-tricks文章

Here's my solution for your case : http://cssdeck.com/labs/ptuzfrep 这是我为您提供的解决方案: 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM