简体   繁体   English

我想创建一个弹出框。 应该使用下拉菜单访问

[英]I want to create a pop up box. That should be accessed using the drop down menu

The following is the code I have so far. 以下是我到目前为止的代码。 Currently the sign-up and join links are on the top left. 目前,注册和加入链接位于左上方。 I want these to be in a drop down menu. 我希望它们在下拉菜单中。 So on the top left I want to have a drop down menu, that when I hover over the menu these two links appear there and when I click them the same pop up appears in the middle of the screen. 因此,在左上角我想要一个下拉菜单,当我将鼠标悬停在菜单上时,这两个链接就会出现在菜单中,而当我单击它们时,屏幕中间会出现一个弹出窗口。

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">

  <title>Clipmarks - Online Bookmark Application</title>
  <meta name="description" content="An online collection of all your bookmarks.">
  <meta name="author" content="Tonye Bezalel Brown">
  <link rel="icon" 
        type="image/png" 
        href="images/clipmarks-favicon.png">

    <style type="text/css">
        body { 
            margin:0;
            font-family: Arial, sans-serif;
            font-size: 11pt;
        }

        a:link, a:visited {
            font-family: Arial, sans-serif, verdana;
            text-decoration: none;
            letter-spacing:1px;
            font-weight: bold;
            color: #686777;
            font-size: 11pt;
        }

        a:hover {
            color: #006cff;
        }

        .content {
            margin: 0 auto;
            position: absolute;
            top: 0;
            width: 100%;
            height: 100%;
        }

        .header {
            height: 49px;
            margin: 0 auto;
            padding: 50px 50px 30px;
            max-width: 900px;
        }

        #header-img-wrap {
            min-width:42px;
            margin: auto auto 2px -30px;
        }

        #header-img-wrap a span {
            font-size: 14pt;
            font-family: Arial;
            font-weight: 650;
            position: absolute;
            padding: 7px;
            margin-top: -3px;
            vertical-align: inherit;
        }   

        .header a img {
            width: 29px;
            height: auto;
        }

        .header-links {
            text-align: right;
            margin-top: -28px;
            margin-right: -50px;
            width: 116px;
            float: right;
        }



        .header li {
            display: inline-block;
            list-style-type: none;
            padding-right: 8px;
        }

        #box {
            width: 99.9%;
            border: 1px #000 solid;
            position: absolute;
            height: 60%;
            overflow: hidden;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: auto;
        }

        #box:hover {
            background:rgba(0, 108, 255, 0.42);
        }

        #boximg {
            width: 630px; 
            height: 140px; 
            position: absolute; 
            right: 200px;
        }

        .footer {
            width: 100%;
            text-align: center;
            position: absolute;
            bottom: 35px;
        }

        #overlay {
            display: none;
            position:absolute;
            top:0;
            width:100%;
            height:100%;
            background: rgba(0,0,0,0.63);
            z-index:15;
        }

        #login, #signup {
            display: none;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: auto;
            z-index: 10000;
            max-width: 26em;
            height: 199px;
            padding: 28px 22px;
            border: 4px solid rgb(197, 218, 255);
            background: white;
        }

        #recoverPassword {
            display: none;
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: auto;
            z-index: 10000;
            max-width: 26em;
            height: 149px;
            padding: 28px 22px;
            border: 4px solid rgb(197, 218, 255);
            background: white;
        }

        form input {
            display: block;
            border: 0 solid black;
            width: 100%;
            height: 32px;
            margin: 0 auto;
            margin-bottom: -14px;
            background: aliceblue;

        }

        form p {
            margin-top: 0;
        }

        form a{
            display: block;
            float: left;
            position: relative;
            vertical-align: bottom;
            width: 112px;
            font-size: 12px !important;
            word-break: break-word;
        }

        #formButton {
            background: transparent;
            margin-right: -7px;
            display: inline;
            width: 61px;
            float: right;
            margin-top: -8px;
            word-break: break-word;
            font-weight: bold;
            color: #7A7A7A;
        }

        #formButton:hover {
            color:#000;
        }

    </style>




</head>


<body onload="move()">
    <div id="overlay" onclick="closeOverlay()">
    </div>
        <div id="login">
            <form action="main.html" method="get" autocomplete="on">
                <input type="text" name="username" autofocus><br /><p>Username (or email address)</p>
                <input type="password" name="password"><br /><p>Password</p>
                <br /><br /><br />
                <a href="#" onclick="recoverPassword()">Forgot Password</a>
                <input id="formButton" type="submit" value="Sign In">
            </form>
        </div>

        <div id="signup">
            <form action="main.html" method="get" autocomplete="on">
                <input type="text" name="username" autofocus><br /><p>Your email address</p>
                <input type="password" name="password"><br /><p>Password</p>
                <br /><br /><br />
                <input id="formButton" type="submit" value="Join">
            </form>
        </div>

        <div id="recoverPassword">
            <form action="index.html" method="get">
                <input type="text" name="username" autofocus><br /><p>Username (or email address)</p>
                <br /><br /><br /><br />
                <input id="formButton" type="submit">
            </form>
        </div>

    <div class="content">

        <div class="header">
            <div id="header-img-wrap">
                <a href="index.html"><img src="images/clipmarks-favicon.png" height="" alt="" title="" /><span>ClipMarks<span></a>
            </div>
        <div class="header-links">
            <li><a href="#" onclick="signin()">Sign In</a></li>
            <li><a href="#" onclick="join()">Join</a></li>
        </div>

        </div>

        <div id="box">
            <img id="boximg" src="images/box-image.jpg" width=""  height="" alt="" title="" />
        </div>

        <div class="footer">
            <a href="http://cs.tru.ca">About Us</a>
        </div> 
    </div>


    <script>
          window.onload = function move() { //makes the box move in relation to the box div
              var d = document.getElementById('boximg');
              var boxh = document.getElementById('box').clientHeight - 120; //keeps the image in the box by subtracting height
              var boxw = document.getElementById('box').clientWidth - 600; //keeps the image in the box by subtracting the width

              document.onmousemove = function calc(e) {
                var x = e.clientX ;
                var y = e.clientY;

                if (x < boxw) {
                    d.style.right = x +'px';
                }

                if (y < boxh) {
                    d.style.bottom = y +'px';
                }

              };
          };


          function closeOverlay() { // function closes the black transparent overlay div by setting the display properties of all the forms to none 
            var ov = document.getElementById('overlay');
            var rp = document.getElementById('recoverPassword');
            var lg = document.getElementById('login');
            var sg = document.getElementById('signup');

            ov.style.display = 'none';
            rp.style.display = 'none';
            lg.style.display = 'none';
            sg.style.display = 'none';
          };



          document.onkeydown = function(evt) { //makes the escape key to call the closeOverlay() function
            evt = evt || window.event;
            if (evt.keyCode == 27) {
                closeOverlay();
            }
          };

          function signin() { //displays the sign in form
            var lg = document.getElementById('login');
            var ov = document.getElementById('overlay');
            ov.style.display = 'block';
            lg.style.display = 'block';


          };

          function recoverPassword() { //displays the recoverPassword form for the user to recover password
            closeOverlay(); 
            var ov = document.getElementById('overlay');
            ov.style.display = 'block';

            var rp = document.getElementById('recoverPassword');
            rp.style.display = 'block';
          };

          function join() { //calls the join form for users to register
            var lg = document.getElementById('signup');
            var ov = document.getElementById('overlay');
            ov.style.display = 'block';
            lg.style.display = 'block';
          };


    </script>
</body>

</html>

That should be fairly easy to do. 那应该很容易做到。 replace the code in your header-links div with this one. 用此代码替换header-links div中的代码。 HTML: HTML:

<ul>
    <li><a href="#">Dropdown</a>
        <ul>
            <li><a href="#" onclick="signin()">Sign In</a></li>
            <li><a href="#" onclick="join()">Join</a></li>
        </ul>
    </li>
</ul>

and add this to your css classes 并将其添加到您的CSS类

CSS: CSS:

ul ul {
    display: none;
}

ul li:hover > ul {
    display: block;
}

I also recommend you remove the negative margins in your .header-links class and add float:left to your #header-img-wrap . 我还建议您删除.header-links类中的负边距,并将float:left添加到#header-img-wrap

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用javascript或PHP,如何使用下拉列表或文本框中的值。 - Using javascript or PHP how can I use the value from a drop down list or a text box. 在从下拉菜单中选择特定选项时,应弹出一个模式表格 - On specific option selection from drop down menu a modal form should pop up 我想添加一个弹出模式框 - I want to add a pop up modal box 使用下拉菜单将链接(带有弹出式div)移动到另一个div - Move a link (with a pop up div) to another div, with a drop down menu 从下拉框中创建一个弹出窗口 - Creating a pop up window from a drop down box 如何使用bootstrap创建下拉菜单? - How can I create a drop-down menu using bootstrap? 想要在现有主菜单中创建下拉菜单 - Want to create drop down menu in my existing main menu 我试图确定变量是否与下拉框中选择的选项匹配。 我怎样才能做到这一点? - I am trying to determine whether a variable matches the option selected in the drop down box. How can I do this? 我有三个下拉按钮我想单击特定的下拉列表并弹出列表并显示在该特定的单击下拉列表上,而不是全部 - I have three drop down button I want to click the specific dropdown and pop up the list and display on the that specific click dropdown , not in all 传单弹出框问题 - 框角上的小标签。 这是某种故障吗? - Issue with Leaflet Pop-up Box - Small tag on corner of box. Is this a glitch of some kind?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM