简体   繁体   中英

Javascript scroll always on bottom

I have a div class called ".chat-scroll". I need that div class always on the bottom like chat.

 $(".chat-scroll").animate({ scrollTop: $(document).height() }, "slow"); 
 .chat-scroll { overflow-y: scroll; height: 200px; padding: 10px; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="chat-scroll"> <ul class="messages list-unstyled"> <li><span class="text">{!! $shout->text !!}</span></li> </ul> </div> 

But does not working.

I wonder why didnt you use {position:fixed} ...

   .chat-scroll {
        overflow-y: scroll;
        height: 200px;
        padding: 10px;
    position:fixed;
    bottom:0;
    right:0;
    }

I think probably you like to practice Jquery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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