这一个使用浮动,而上面的其他优秀答案使用定位。这取决于你选择的。各有其优点和缺点。
CSS
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend, button,
table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; vertical-align: baseline; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; }
body { font: normal 100%/1.5em "Helvetica Neue", Helvectica, Arial, sans-serif; color: #353E34; background: #FFF; text-align: left; }
html>body { font-size: 16px; }
.content-wrapper { width: 100%; float: left; }
.content { margin-right: 220px; background: #9CC; }
.sidebar { float: right; width: 200px; margin-left: -200px; background: #FDE95E; }
.inner { margin: 10px; }
.footer { clear: left; width: 100%; background: black; color: #FFF; text-align: center; padding: 4px 0; }
HTML
<div class="content-wrapper">
<div class="content">
<div class="inner">
<p>Content</p>
</div>
</div>
</div>
<div class="sidebar">
<div class="inner">
<p>Sidebar</p>
</div>
</div>
<div class="footer">
<p>Footer</p>
</div>
的溶液是否有以确保A和B是相同的高度?或者他们已经是同等高度了?或者没有关系? – thirtydot
@thirtydot - 他们是相等和固定高度(更新的问题) – UpTheCreek
经典的“简单解决方案”已经发布。一个'div','float:right',另一个'margin-right'等于右边'div'的宽度。 – thirtydot