我试过找到一个可以理解的答案,但放弃了.
为了在横向网站(例如thehorizontalway.com)上拥有dymnamic内容(如博客文章和图片),你必须为像素中的BODY设置一个固定的宽度,对吧?因为你在其中使用浮动元素,否则会破坏和包裹页面,具体取决于浏览器的宽度.
编辑!这个特定的值可以用jQuery 计算,多亏了:)在这个例子中,一个额外的值被添加到总大小,可以用于浮动元素之前的内容.现在身体有一个动态的宽度!
我最初的想法是让jQuery为我们计算:('每个帖子宽度'*'号码数')+ 250(额外内容)
HTML代码
<body style="width: ;"> <!-- Here we want a DYNAMIC value -->
<div id="container">
<div id="menu"></div> <!-- Example of extra content before the floats -->
<div class="post">Lorem</div>
<div class="post">Lorem</div>
<div class="post">Lorem</div> <!-- Floated elements that we want the sizes of -->
<div class="post">Lorem</div>
</div>
...
<!-- So if these posts were 300px exept the last that was 500px wide, then the BODY WIDTH should …Run Code Online (Sandbox Code Playgroud)