Working with CSS, top propery in JQuery

前端 未结 3 1184
余生分开走
余生分开走 2021-01-29 10:52

I want to change top position of class bbb after 100 ms, but it took out that .css(top) does not work.

Please help.



&l         


        
3条回答
  •  长情又很酷
    2021-01-29 11:33

    As others have already said, if you want to use the top attribute you need to give

    position:relative;
    

    to the element. This way the element will be set relative to his position and this could be a little tricky. By the way i usually prefer to make a container box relative ad put the positionable element absolute in it, so it will be displayed relative to his container:

    .container{
        position:relative;
    }
    
    .element{
        position:absolute;
    }
    

    This is the html:

提交回复
热议问题