Home > front end >  Could you tell me the scroll up js how to modify
Could you tell me the scroll up js how to modify

Time:09-25





<meta HTTP - equiv="content-type" Content="text/HTML. Charset=utf-8 "/& gt;
Demo



<style>
* {
padding: 0;
margin: 0;
}

Body {
Width: 98%;
Height: 15000 px;
margin: 0 auto;
}

Li {
list-style: none;
}

The div {
Width: 500 px;
height: 100px;
display: block;
margin: 0 auto;
Margin - top: 50 px;
overflow: hidden;
}

The div ul {
display: block;
}

The div ul li {
Height: 20 px;
The line - height: 20 px;
}

Div ul li: NTH child (odd) {
-Background: # CCC;
}
</style>

<body>

  • 111111111


  • 222222222


  • 333333333


  • 444444444


  • 555555555


  • 666666666


  • 777777777


  • 888888888


  • 999999999







<script>
Var ulo=document. QuerySelector (" # ulo ");
Var div1=document. QuerySelector (" div ");
Var con2=document. QuerySelector (" # con2 ");
Con2. InnerHTML=ulo. InnerHTML;
SetInterval (function () {
If (div1. ScrollTop & gt;=ulo. OffsetHeight) {
Div1. ScrollTop=0;
} else {
Div1. ScrollTop++;
}
}, 50)
</script>




Above is a text scrolling code, how to remove & lt; Ul id="con2" & gt; Don't have to copy a ul this method, text scrolling,

CodePudding user response:





<meta HTTP - equiv="content-type" Content="text/HTML. Charset=utf-8 "/& gt;
Demo



<style>
* {
padding: 0;
margin: 0;
}

Body {
Width: 98%;
Height: 15000 px;
margin: 0 auto;
}

Li {
list-style: none;
}

The div {
Width: 500 px;
height: 100px;
display: block;
margin: 0 auto;
Margin - top: 50 px;
overflow: hidden;
}

The div ul {
display: block;
}

The div ul li {
Height: 20 px;
The line - height: 20 px;
}

Div ul li: NTH child (odd) {
-Background: # CCC;
}
</style>

<body>

  • 111111111


  • 222222222


  • 333333333


  • 444444444


  • 555555555


  • 666666666


  • 777777777


  • 888888888


  • 999999999



- & gt;



<script>
Var ulo=document. QuerySelector (" # ulo ");
Var div1=document. QuerySelector (" div ");
//var con2=document. QuerySelector (" # con2 ");
//con2. InnerHTML=ulo. InnerHTML;
SetInterval (function () {
//if (div1 offsetHeight & gt;=ulo. OffsetHeight) {
If (div1. ScrollTop & gt; {
=80)Div1. ScrollTop=0;
} else {
Div1. ScrollTop++;

}

}, 50)
</script>


  • Related