滚动以更改图像时的背景图像

时间:2020-04-25 09:59:02

标签: javascript html css

如何获取图像(是否作为背景图像)。我唯一想做的就是向下滚动以更改图像时如何在HTML页面上执行此操作?我已在其中添加了这两个图像

 <!DOCTYPE html>
<html>
<head>
<title> Tv-Shows / Movies </title>
<style type="text/css">
.auto-style1 {
    margin-top: 0px;
}
</style>
</head>
<body>

<h1>Tv Shows<img alt="" height="591" src="image1.png" width="1024"></h1>

<p id="demo">Top 5 Tv shows,is Prison Break,Wayward Pines,Mentalist,Lost,Usa shooter</p>
<p id="demo1">Top 5 movies,is Prison Break,Wayward Pines,Mentalist,Lost,Usa shooter</p>


<button onclick="myFunction()">click me</button>
<button onclick="mySec()">click me</button>

<script>
function myFunction() {
  var x = document.getElementById("demo");
  x.style.fontSize = "25px"; 
  x.style.color = "red"; 
}
</script>
<script>
function mySec() {
  var x = document.getElementById("demo1");
  x.style.fontSize = "25px"; 
  x.style.color = "green"; 
}
</script>



<img alt="" class="auto-style1" height="464" src="citycas.jpg" width="1355">



</body>
</html>

0 个答案:

没有答案