English 中文(简体)
特定领域的剪页内容?
原标题:Scroll page content within specific area?
  • 时间:2010-08-03 19:01:41
  •  标签:
  • html
  • css

I m 设计一个网站,在固定主编外边定点。 该中心为内容保留了一块。

当用户浏览时,我想到所有内容(除了指固定的外,还指固定的外在导航要素)都留在该中心的边境之内。

Here s a quick mockup of what I mean: alt text

我非常容易地将中心部分的溢出财产放到汽车中,而且一切都留在车内。 然而,非常重要的是,不应在这一要素的边缘出现滚动条。

基本上,我想知道如何做到:

  • Restrict content to that area (perhaps I could change the size and positioning of the body element -- is that allowed? -- and then position the fixed elements outside of the body.
  • Hide the scroll bar that appears inside the div when using overflow:auto

任何帮助都将受到高度赞赏。

最佳回答

如有可能,你应将固定职位要素分成4个单独的部分(顶、左、右和底层)。 然后,确保你根据各自的宽度和高度把内容放在中心位置上,这样内容就会重叠:

<><><><>>><>>>>><>>>>>>

<!-- 4 fixed position elements that will overlap your content -->
<div id="top"></div>
<div id="left"></div>
<div id="right"></div>
<div id="bottom"></div>

<div id="content">
  <!-- Your content -->
</div>

<>CSS

html, body {
  height: 100%;   
}

#top, #left, #right, #bottom {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2;
  background: red;
}

#top, #bottom {
  width: 100%;
  height: 20px;
}

#bottom {
  top: auto;
  bottom: 0;
}

#left, #right {
  height: 100%;
  width: 20px;
}

#right {
  left: auto;
  right: 0;
}

#content {
  position: relative;
  z-index: 1;
  padding: 25px; /* prevent content from being overlapped */
}

可查阅

还注意到立场:内容领域的相对立场。 这一点是正确的z-index,其内容在固定栏目下显示。

如果你注意IE6/7支持的话,你需要增加一个 rel=“noreferer”>CSS表示 固定,以便在awesome浏览器上适当开展工作。

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签