简体   繁体   English

CSS div 固定定位

[英]CSS div fixed positioning

I have a div that contains a smaller div with some text.我有一个 div,其中包含一个带有一些文本的较小 div。 The container div has a webkit transition that moves it off the screen.容器 div 有一个 webkit 转换,可以将其移出屏幕。 I want the smaller div to move with it, until it gets to the edge of the page, then remain fixed, almost as if it gets 'stuck' on the side of the page, while the container div continues to move underneath it out of sight.我希望较小的 div 与它一起移动,直到它到达页面的边缘,然后保持固定,几乎就像它被“卡在”页面的一侧一样,而容器 div 继续在它下面移动视线。 Can this be done?这可以做到吗?

//CSS
.move{
    -webkit-transition-property:left;
    -webkit-transition-timing-function:ease-in-out;
    -webkit-transition-duration:1s;
    left:-200px;
}

//HTML
<div onclick="this.className='move'">
     <div>
         some text here
     </div>
</div>

Here's an example for you: http://jsfiddle.net/LjjRM/这是给你的一个例子: http://jsfiddle.net/LjjRM/

A couple points:几点:

1.) jQuery 1.) jQuery

2.) position: absolute 2.) position:绝对

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM