2016-08-19 66 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!請避免*只是*在您的答案中張貼鏈接。鏈接可能會變壞,並且可能證明您的答案在未來相關時非常重要 - 這適用於代碼片段和參考文本。相反,考慮添加一些相關的代碼片段來回答這個問題,以及它如何工作的簡短解釋(我們開發人員喜歡知道東西是如何工作的);並盡一切可能 - 包含一個供參考的鏈接 –