mramine364

rtl & ltr with bg img

Jan 14th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.56 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <meta charset="UTF-8">
  4.     <title>Document</title>
  5. </head>
  6. <style>
  7.     .container{
  8.         background-image: url("pic.png");
  9.         width: 850px;
  10.         height: 500px;
  11.         position: relative;
  12.         margin: auto;
  13.         overflow: hidden;
  14.     }
  15.     .t1{
  16.         position: absolute;
  17.         top: 5;
  18.         color: red;
  19.         font-size: 25pt;
  20.         width: 100%
  21.     }
  22.     .t2{
  23.         position: absolute;
  24.         bottom: 5;
  25.         font-size: 25pt;
  26.         width: 100%;
  27.         text-align: right;
  28.     }
  29.     p{
  30.         margin: 0;
  31.         display: inline-block;
  32.         position: relative;
  33.     }
  34. </style>
  35. <body>
  36.     <div class="container">
  37.         <div class="t1">
  38.             <p>
  39.                 الكتاب من هنا من اليسار الى اليمين متحركة
  40.             </p>
  41.         </div>
  42.         <div class="t2">
  43.             <p>
  44.                 الكتاب من هنا من اليمين الى اليسار متحركة
  45.             </p>
  46.         </div>
  47.     </div>
  48.     <script>
  49.     var t1 = document.querySelector('.t1 p');
  50.     var t2 = document.querySelector('.t2 p');
  51.     setInterval(function () {
  52.         var i,j;
  53.         i = t1.style.left.indexOf("p");
  54.  
  55.         if( i!=-1 && t1.style.left.substr(0,i)>=850 )
  56.             t1.style.left = 5-456+"px";
  57.         else{
  58.             console.log()
  59.             if( i == -1 ){
  60.                 t1.style.left += 4;
  61.             }else{
  62.                 t1.style.left = parseInt(t1.style.left.substr(0,i))+4+"px";
  63.             }
  64.         }
  65.  
  66.         j = t2.style.right.indexOf("p");
  67.         console.log(t2.style.right.substr(0,j))
  68.         if( j!=-1 && t2.style.right.substr(0,j)>=850 )
  69.             t2.style.right = 5-456+"px";
  70.         else{
  71.             console.log()
  72.             if( j == -1 ){
  73.                 t2.style.right += 4;
  74.             }else{
  75.                 t2.style.right = parseInt(t2.style.right.substr(0,j))+4+"px";
  76.             }
  77.         }
  78.     },100);
  79.     </script>
  80. </body>
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment