【发布时间】:2021-06-23 03:47:46
【问题描述】:
我想在左侧有不同的按钮,打开不同的链接,但我想让关闭按钮成为通用按钮。我不希望它关心打开不同链接的不同按钮,我只希望它关闭打开的任何视频(它有效)。但是,我希望这些按钮可以打开不同的链接。我怎样才能做到这一点?有人可以帮忙吗?
<!DOCTYPE html>
<html lang="hu">
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background-image: url('background.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
margin: 0;
padding: 0;
}
.focim {
color: white;
margin-bottom: 50px !important;
text-align: center;
}
#videoIframe {
display: none;
position: absolute;
margin-left: 33vw;
margin-top: -65vh;
border-style: solid;
border-width: 5px;
border-color: white;
}
#videoIframe:hover {
border-style: solid;
border-width: 5px;
border-color: rgba(231, 231, 10, 0.5);
}
#stop_vid {
display: none;
position: absolute;
transition: 0.3s;
padding: 5px 8px;
text-align: center;
text-decoration: none;
font-size: 13px;
margin: -520px 2px;
cursor: pointer;
border-radius: 50%;
left: 90%;
margin-bottom: 500px;
background-color: rgba(250, 250, 250, 0.6);
}
#stop_vid:hover {
background-color: rgba(255, 255, 255, 1);
transform: rotate(90deg);
}
#open_vid {
position: relative;
text-align: center;
transition: all ease 0.1s;
margin-left: 50%;
margin-right: 50%;
background: linear-gradient(to bottom, #ffffff 5%, #f6f6f6 100%);
background-color: #ffffff;
border-radius: 42px;
border: 3px solid #dcdcdc;
display: inline-block;
cursor: pointer;
color: #666666;
font-family: Georgia;
font-size: 15px;
font-weight: bold;
padding: 10px 15px;
text-decoration: none;
transition: all ease 1s;
margin-bottom: 20px;
width: 13vw;
overflow: hidden;
}
#open_vid:hover {
background: linear-gradient(to bottom, #c4f6f6 5%, #fffff3 100%);
background-color: #f6f6f6;
width: 16vw;
}
#open_vid:active {
position: relative;
top: 1px;
}
@media all and (max-width:30em) {
#open_vid {
display: block;
margin: 0.4em auto;
}
}
.gombok {
width: 50px;
height: 500px;
}
@media screen and (max-width: 700px) {
#videoIframe {
width: 50vw;
height: 300px;
}
}
@media screen and (max-width: 700px) {
#open_vid:hover {
width: 50vw;
}
#open_vid {
overflow: hidden;
}
}
button:focus {
outline: none;
}
</style>
</head>
</head>
<body>
<body>
<!--headline-->
<div class="focim">
<h1>Oktató videók: Matematika</h1>
</div>
<!--Buttons (gombok in hungarian)-->
<div class="gombok">
<button type="button" onclick="nyit()" id="open_vid">Lineáris és abszolút érték függvények ábrázolása</button>
<button type="button" onclick="nyit()" id="open_vid">Négyzetes és gyökös függvények ábrázolása/elemzése</button>
<button type="button" onclick="nyit()" id="open_vid">Egy ingás kísérlet</button>
</div>
<!--video closer button-->
<div class="container">
<button type="button" onclick="zar()" id="stop_vid"><i class="fa fa-close"></i></button>
</div>
<!--video links-->
<div class="video_container">
<div class="videoIframe">
<iframe id="videoIframe" width="560" height="380" src="https://www.youtube.com/embed/h-paQtzKhZ8" frameborder="0" allowfullscreen=""></iframe>
<iframe id="videoIframe" width="560" height="380" src="https://www.youtube.com/embed/Cr6gwI9NwXE" frameborder="0" allowfullscreen=""></iframe>
<!--Teszt apex link-->
<iframe id="videoIframe" width="560" height="380" src="https://youtube.com/embed/CG6MMLbGl_U" frameborder="0" allowfullscreen=""></iframe>
<!--Teszt apex link-->
</div>
</div>
</body>
<!--nyit = open, zar = close-->
<script type="text/javascript">
function zar() {
document.getElementById("videoIframe").style.display = "none";
var ysrc = document.getElementById("videoIframe").src;
var newsrc = ysrc.replace("&autoplay=1", "");
document.getElementById("videoIframe").src = newsrc;
document.getElementById("stop_vid").style.display = "none";
document.getElementById("open_vid").style.display = "inline-block";
}
function nyit() {
document.getElementById("videoIframe").style.display = "inline-block";
document.getElementById("stop_vid").style.display = "inline-block";
}
</script>
</body>
</html>
【问题讨论】: