html - 将固定的 navigation-div 对齐到右侧的外部 div

标签 html css

导航栏位于 container-div 的左侧。但我希望它坚持正确。我尝试了几件事,但都没有奏效。所以这是准系统代码。 如何获得一个固定在右侧的导航栏,恰好在我的 container-div 结束的地方结束?

PS:必须修复它,因为我希望导航保留在浏览器窗口的顶部,无论用户向下滚动多少。

#container {
    margin: 0 auto;
    width: 820px;
}

#navigation {
    position: fixed;
    z-index: 10000;
    display:block;
}

最佳答案

好的,我猜测了您的 HTML 代码并为您构建了这个代码:http://jsfiddle.net/vdL6b/

根据我的想象,您想要实现的目标是,可以使用以下两种解决方案之一:

  1. 删除 position:fixed; 并添加 float: right; 到您的导航 CSS。
  2. 添加right: 0;定义位置。

我选择了后者。 Here's an example使用第一个。

关于html - 将固定的 navigation-div 对齐到右侧的外部 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24398248/

相关文章:

html - 中间框居中变宽,左右浮动直连

php - WordPress如何动态生成页面?

javascript - 单击按钮时 mdl-layout__container 无限滚动

css - 在 html5 的 Canvas 上放置一个 div

html - 使盒子始终具有相同的高度,箭头位于相同的位置

javascript - JS : How would I display a decrementing value through an html header?(及更多)

javascript - 如何使用 html、css 和 js 文件构建可在任何 Android 手机上运行的 APK 文件

CSS - Bootstrap 导航栏元素垂直居中

html - 如何居中和左对齐图像?

javascript - 将 JSON 对象绑定(bind)到 HTML 元素