我正在尝试制作包含行列表的弹出窗口:
在第1行,它应显示支持。在第2行,它应显示Contact,在第3行,它应显示Demo。
我可以按照w3schools链接http://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_popup创建包含一行的弹出窗口,但我不知道如何创建具有多行的弹出窗口。
我在w3schools链接中使用的代码如下所示:
<!DOCTYPE html> <html> <style> /* Popup container - can be anything you want */ .popup {
position: relative;
display: inline-block;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
/* The actual popup */ .popup .popuptext {
visibility: hidden;
width: 160px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -80px; }
/* Popup arrow */ .popup .popuptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent; }
/* Toggle this class - hide and show the popup */ .popup .show {
visibility: visible;
-webkit-animation: fadeIn 1s;
animation: fadeIn 1s; }
/* Add animation (fade in the popup) */ @-webkit-keyframes fadeIn {
from {opacity: 0;}
to {opacity: 1;} }
@keyframes fadeIn {
from {opacity: 0;}
to {opacity:1 ;} } </style> <body style="text-align:center">
<h2>Popup</h2>
<div class="popup" onclick="myFunction()">Click me to toggle the popup! <span class="popuptext" id="myPopup">Support</span> </div>
<script> // When the user clicks on div, open the popup function myFunction() {
var popup = document.getElementById('myPopup');
popup.classList.toggle('show'); } </script>
</body> </html>
答案 0 :(得分:0)
快速尝试按照以下步骤设计您想要的内容
1- open you mentioned link
2-将html代码更改为:
<div class="popup" onclick="myFunction()">Click me to toggle the popup!
<div class="popuptext" id="div">
<div><span id="myPopup">Support</span><br/></div>
<div><span id="myPopup1">Contact</span><br/></div>
<div><span id="myPopup2">Demo</span><br/></div>
</div>
</div>
3-将myFunction()
代码块更改为:
var popup = document.getElementById('div');
popup.classList.toggle('show');
4-将此css
课程添加到style
head
元素
.popup .popuptext div{
text-align: center;
background:#ad4747;
border-radius: 6px;
width: 160px;
margin-top:2px;
}
5-结束运行并查看结果
但是你知道有几种方法可以通过前端工具设计弹出菜单,
但我的解决方案是一个快速的设计希望给你一些帮助。