IE7/IE8兼容渲染浮动布局错误

发布于 2024-09-19 11:21:38 字数 885 浏览 4 评论 0原文

我有一个带有右侧边栏和左侧主要内容区域的网站。代码如下所示:

<div class="leftside">leftsidecontent</div>
<div class="leftside">leftsidecontent</div>
<div class="leftside">leftsidecontent</div>
<div class="leftside">leftsidecontent</div>
<div class="rightside">rightsidecontent</div>
<div class="rightside">rightsidecontent</div>
<div class="rightside">rightsidecontent</div>

with

.leftside
{
  float:left;
  width:710px;
}
.rightside
{
  margin-left:720px;
}

(请参阅实际站点 http://blog.stephenkiers.com/

原因它是这样编码的,因为左侧内容很重要,我想成为视障访问者访问的第一个数据;而不是他们每次都必须跳过所有的绒毛!

该代码适用于 FF、IE8、Safari 等;但在 IE7 中,右侧 div 会清除浮动 div。

我很乐意接受您的任何建议。我对如何解决这个问题有一些想法;但它们都涉及相当大的重写。

谢谢!

I have a site with a right sidebar and a left main content area. Code looks like this:

<div class="leftside">leftsidecontent</div>
<div class="leftside">leftsidecontent</div>
<div class="leftside">leftsidecontent</div>
<div class="leftside">leftsidecontent</div>
<div class="rightside">rightsidecontent</div>
<div class="rightside">rightsidecontent</div>
<div class="rightside">rightsidecontent</div>

with

.leftside
{
  float:left;
  width:710px;
}
.rightside
{
  margin-left:720px;
}

(see actual site at http://blog.stephenkiers.com/)

Reason it is coded this way is so that because the leftsidecontent is important and I want to be first data accessed by visually impaired visitors; instead of them having to skip all the fluff every time!

The code works in FF, IE8, Safari etc; but in IE7 the rightside divs clear the floated divs.

I would love any suggestions you may have. I have some ideas about how to fix it; but they all involve pretty big rewrites.

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

西瓜 2024-09-26 11:21:38

为什么不尝试将内容包装成两列,如下所示 示例

CSS:

.leftside {
  float:left;
  width:710px;
}

.rightside {
  float: left;
  margin-left: 20px;
}

.contentBlock { margin-bottom: 10px; background: #ccc; padding: 8px; }

HTML:

<div class="leftside">
  <div class="contentBlock">
    <p>main stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>main stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>main stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>main stuff goes here</p>
  </div>
</div>
<div class="rightside">
  <div class="contentBlock">
    <p>secondary stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>secondary stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>secondary stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>secondary stuff goes here</p>
  </div>
</div>

这样,左侧和右侧只是布局元素,与内容隔离。

对于视障访问者来说,另一个好建议是在页面顶部添加链接,让用户可以直接跳到内容部分,并使用 css 将其隐藏在布局中:

.skipToLinks { position: absolute; top: -100px;}

why don't you try wrapping the content stuff into two columns like this example

The CSS:

.leftside {
  float:left;
  width:710px;
}

.rightside {
  float: left;
  margin-left: 20px;
}

.contentBlock { margin-bottom: 10px; background: #ccc; padding: 8px; }

The HTML:

<div class="leftside">
  <div class="contentBlock">
    <p>main stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>main stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>main stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>main stuff goes here</p>
  </div>
</div>
<div class="rightside">
  <div class="contentBlock">
    <p>secondary stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>secondary stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>secondary stuff goes here</p>
  </div>
  <div class="contentBlock">
    <p>secondary stuff goes here</p>
  </div>
</div>

This way the leftside and rightside are just layout elements and are isolated from the content.

Another good tip for visually impaired visitors is to have links at the top of the page to allow users to skip directly to content sections and hide them from your layout with css:

.skipToLinks { position: absolute; top: -100px;}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文