內容高度大於div高度是內容自動滾動

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.7.1/jquery.min.js"></script>

</head>

<style>div.marquee{overflow:hidden;background:#ccc;width:400px;height:140px;line-height:30px}</style>

<body>

    <div class="marquee">

        該系統於2017-06-21進行維護,望相互告知!!!<br/>

        該系統於2017-06-21進行維護,望相互告知!!!<br/>

        該系統於2017-06-21進行維護,望相互告知!!!<br/>

        該系統於2017-06-21進行維護,望相互告知!!!<br/>

        該系統於2017-06-21進行維護,望相互告知!!!<br/>

        該系統於2017-06-21進行維護,望相互告知!!!<br/>

        該系統於2017-06-21進行維護,望相互告知!!!<br/>

        該系統於2017-06-21進行維護,望相互告知!!!<br/>

    </div>

</body>

<script>

    $('div.marquee').each(function () {

        if (this.scrollHeight > this.offsetHeight) $(this).html('<marquee behavior="scroll" direction="up" scrollamount="1" height="140" οnmοuseοver="this.stop()" οnmοuseοut="this.start()">'+this.innerHTML+'</marquee>');

    });

</script>

</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章