css - 绝对定位导致水平滚动

标签 css css-position

我有一个云,它通过 CSS3 动画从屏幕内部移动到屏幕外。当云离开屏幕时,屏幕会水平滚动,这并不理想。我可以使用 CSS 隐藏滚动条,但我想阻止滚动。

#c-2 {
background:url(clouds.png) no-repeat;
width:161px;
height:94px;
position:absolute;
top:40%;
right:0%;
animation:CloudB 20s 1s infinite alternate ease-in-out;
-moz-animation:CloudB 20s 1s infinite alternate ease-in-out;
-webkit-animation:CloudB 20s 1s infinite alternate ease-in-out;
-o-animation:CloudB 20s 1s infinite alternate ease-in-out;
}

@keyframes CloudB {
    0%   { right:0%; top:40%; }
    100% { right:-10%; top:40%; }
}

@-moz-keyframes CloudB {
    0%   { right:0%; top:40%; }
    100% { right:-10%; top:40%; }
}

@-webkit-keyframes CloudB {
    0%   { right:0%; top:40%; }
    100% { right:-10%; top:40%; }
}

@-o-keyframes CloudB {
    0%   { right:0%; top:40%; }
    100% { right:-10%; top:40%; }
}

http://energycenter.herokuapp.com/

最佳答案

试试这个 - http://jsfiddle.net/m3af2/

body {
    background-color: #99CCE8;
    margin: 0;
    line-height: 1;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    position: relative;
}

关于css - 绝对定位导致水平滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11904561/

相关文章:

html - Bootstrap 对齐标签

jquery - Bootstrap 轮播,自动循环然后停止

css - 如果我使用 XHTML 4.01 Strict,我应该避免使用 HTML5 不支持的标签吗?

javascript - 移动网站 : -webkit-overflow-scrolling: touch conflicts with position:fixed

css - 溢出溢出:hidden

html - 绝对父级与 z-index :1000 重叠绝对子级 div

Jquery动态创建具有增量div id的表

php - 如何实现网页的那个移动的盒子(屏幕纸?)?

html - 带有ul和左右图标的导航栏 : icons on the right get pushed down

css - 通知后台位置问题