我开始用Metro UI创建一个小网站来教育自己。
当我用鼠标将鼠标悬停在上面时,我想制作一张显示一些信息的图片,一旦按下它,就会弹出一个对话框。
但不知怎的,关闭按钮不做任何事情。
关闭按钮不会执行任何操作。单击对话框本身或在磁贴上再次关闭对话框,但单击X不会执行任何操作。
我想让关闭按钮满足他的目的,如果我点击它就关闭对话框。
这是我的代码,希望你能帮助我。
<!DOCTYPE html>
<html lang="de">
<html>
<head>
<link href="build/css/metro.css" rel="stylesheet">
<link href="build/css/metro-icons.css" rel="stylesheet">
<script src="build/js/jquery.js" > </script>
<script src="build/js/metro.js" > </script>
<meta charset="utf-8"/>
</head>
<body bgcolor="#4da6ff">
<div class="app-bar">
<span class="app-bar-divider"> </span>
<ul class="app-bar-menu">
<li> <a href="index.html">Startseite</a> </li>
<li> <a href="" class="dropdown-toggle">Unterkünfte</a>
<ul class="d-menu" data-role="dropdown">
<li> <a href="Austatttung.html">Die Austattung</a> </li>
<li> <a href="Service.html">Unser Service</a> </li>
<li> <a href="Preise.html">Preise</a> </li>
</ul>
</li>
<li> <a href="" class="dropdown-toggle">Bildergalerie</a>
<ul class="d-menu" data-role="dropdown">
<li>
<a href="Wohnungen.html">
<span class="mif-file-picture"> Ferienwohnungen
</span>
</a>
</li>
<li>
<a href="Brandenburg.html">
<span class="mif-file-picture"> Brandenburg a.d.H
</span>
</a>
</li>
</ul>
</li>
<li> <a href="Reservierung.html">Reservierungsanfrage</a></li>
<li> <a href="Anfahrt.html">Anfahrt</a>
<span class="mif-automobile mif-1x"> </span>
</li>
<li> <a href="Kontakt.html">Kontakt</a></li>
<li> <a href="Impressum.html">Impressum</a><li>
</ul>
</div>
<div class="tile-big">
<div class="tile-content" onclick="toggleMetroDialog('#dialog')">
<div class="image-container">
<div class="frame" >
<img src="bilder/fox.jpg">
<div data-role="dialog" id="dialog" class="padding20" data-close-button="true">
<h1>Ahihahihahi Ahihahihahi Ahihahihahi!</h1>
</div>
</div>
<div class="image-overlay">
<b>What does the fox say ?</b>
</div>
</div>
</div>
</div>
<div class="tile-big">
<div class="tile-content">
<img src="bilder/badhbruecke.jpg" data-role="fit-image" data-format="accurate">
</div>
</div>
<script>
function showDialog(id)
{
var dialog = $(id).data('dialog');
if (!dialog.element.data('opened'))
{
dialog.open();
}
else
{
dialog.close();
}
}
</script>
</body>
</html>
答案 0 :(得分:1)
我上次更改了代码,但它仍然几乎相同。我发现我的试验和错误的问题,并帮助我的CO。我不得不从我的瓷砖大的div之外的对话框中创建div,但在app-bar内。
<!DOCTYPE html>
<html lang="de">
<html>
<head>
<link href="build/css/metro.css" rel="stylesheet">
<link href="build/css/metro-icons.css" rel="stylesheet">
<script src="build/js/jquery.js" > </script>
<script src="build/js/metro.js" > </script>
<meta charset="utf-8"/>
</head>
<body bgcolor="#4da6ff">
<div class="app-bar">
<span class="app-bar-divider"> </span>
<ul class="app-bar-menu">
<li> <a href="index.html">Startseite</a> </li>
<li> <a href="" class="dropdown-toggle">Unterkünfte</a>
<ul class="d-menu" data-role="dropdown">
<li> <a href="#" class="dropdown-toggle">Wohnungen</a>
<ul class="d-menu" data-role="dropdown">
<li> <a href="Ausstattung.html">Die Austattung</a> </li>
<li> <a href="Bildergalerie.html">Bildergalerie</a> </li>
</ul>
</li>
<li> <a href="Service.html">Unser Service</a> </li>
<li> <a href="Preise.html">Preise</a> </li>
</ul>
</li>
<li> <a href="Umgebung.html">Die Umgebung</a></li>
<li> <a href="" class="dropdown-toggle">Sonstiges</a>
<ul class="d-menu" data-role="dropdown">
<li><a href="Reservierung.html">Reservierungsanfragen</a></li>
<li><a href="Anfahrt.html">Anfahrt</a></li>
<li><a href="Hausordnung.html">Hausordnung</a></li>
<li><a href="WLAN.html">W-LAN Nutzung</a></li>
</ul>
</li>
<li> <a href="Kontakt.html">Kontakt</a></li>
<li> <a href="Impressum.html">Impressum</a><li>
</ul>
</div>
<div class="tile-big" onclick="toggleMetroDialog('#dialog')">
<div class="tile-content">
<div class="image-container">
<div class="frame" >
<img src="bilder/fox.jpg">
</div>
<div class="image-overlay">
<b>What does the fox say ?</b>
</div>
</div>
</div>
</div>
<div class="tile-big">
<div class="tile-content">
<img src="bilder/badhbruecke.jpg" data-role="fit-image" data-format="accurate">
</div>
</div>
<div data-role="dialog" id="dialog" class="padding20" data-close-button="true">
<h1>Ahihahihahi Ahihahihahi Ahihahihahi!</h1>
</div>
<script>
function showDialog(id)
{
var dialog = $(id).data('dialog');
if (!dialog.element.data('opened'))
{
dialog.open();
}
else
{
dialog.close();
}
}
</script>
</body>
</html>