html - css position absolute and fixed 无法正常工作

标签 html css scroll position

有一个侧边栏,我们希望它滚动。很明显 position:fixedposition:absolute 应该可以解决问题,但他们没有!

position:fixed 会发生以下情况:

侧边栏在滚动时出现故障并中断并且行为异常

position:absolute 会发生以下情况:

侧边栏滚动而不是停留在原地。

这是侧边栏的 css(不正确的 id 名称)

#sidebar{
font-family: 'Jura', sans-serif; 
position: fixed; 
margin-top:80px; 
margin-left:1020px;
font-size:18px;
padding-top:0px; 
padding-bottom:17px; 
text-align:center; 
height:420px; 
width:300px; 
overflow:hidden;
solid #000000;
color:#000000;
-webkit-transition: opacity 0.3s linear;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
background-color:transparent;
opacity: 1;
z-index:999;
}

this is a link to the blog因此您可以使用开发人员工具检查故障以及到底发生了什么。

为什么定位如此奇怪,如何解决?

这发生在 safari 和 chrome 中,我没有安装 firefox 或 internet explorer,所以我不确定这些浏览器的响应

故障图片,将侧边栏图像拆分,偶尔会显示一些文本:

enter image description here

最佳答案

从带有四字母 F 字的元素中移除 overflow:hidden

#???? {
    font-family: 'Jura', sans-serif;
    position: fixed;
    margin-top: 80px;
    margin-left: 1020px;
    font-size: 18px;
    padding-top: 0px;
    padding-bottom: 17px;
    text-align: center;
    height: 420px;
    width: 300px;
    /*overflow: hidden;*/ <---- remove for "glitch" to go away
    color: #000000;
    -webkit-transition: opacity 0.3s linear;
    -webkit-transition: all 0.3s ease-in-out;
    -moz-transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    background-color: transparent;
    opacity: 1;
    z-index: 999;
}

该元素被命名为删节(我假设)F 字!

关于html - css position absolute and fixed 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16574460/

相关文章:

javascript - 为什么在悬停时更改源时这些 SVG 图像无法正确加载?

javascript - 继承颜色然后使其更暗/更亮

html - 使用 border-radius 时内容出现在一个 Angular 上

CSS 列表下拉菜单

css - 悬停时线性渐变?

javascript - JS 触摸事件 : Y Coordinates greater than Window Height

html - CSS Positioning Issue : When I stretch out my browser, 我的图片位置会变

html - z-index 和堆叠顺序 - 使 child 低于 parent 但高于叔叔

javascript - 用于用户协议(protocol) View 、检测启用按钮的 AngularJS 指令在移动 safari 上不起作用

ios - 自定义 didSelectAnnotationView 不在 map 中滚动