简体   繁体   English

HTML <div> 似乎没有得到认可

[英]html <div> doesn't seem to get recognised

I have 2 divisions. 我有2个师。 One for the header( head-top ) and other for the rest of the space( centre ) in the page as follows. 如下所示,一个用于标题( head-top ),另一个用于页面的其余空间( centre )。 I have attached click events to the elements in header. 我已将click事件附加到标题中的元素。 But these elements don't seem to function. 但是这些元素似乎没有作用。 I cannot click the toggle menu. 我无法单击切换菜单。 Nothing Happens. 什么都没发生。 I have 2 buttons and a toggle menu in the menu bar. 我在菜单栏中有2个按钮和一个切换菜单。

HTML: HTML:

<div class="head-top">
            <div class="menu-links">
                <ul class="toggle-menu">
                    <li class="toggle">
                        <span class="toggle-menu-bar"></span>
                        <span class="toggle-menu-bar"></span>
                        <span class="toggle-menu-bar"></span>
                    </li>
                    <li class="content0" style="display: none">
                        <ul>
                            <li><a href="#" id="home">Home</a></li>
                            <li><a href="#" id="explore">Explore</a></li>
                            <li><a href="#" id="searcha">Search</a></li>
                            <li><a href="#" id="recent">Recent</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div id="b1">Sign Up</div>
            <div id="b2">Upload</div>
        </div>

            <div class="center">
                <div class="middle">
                    <h1>The Starry Night</h1>
                    <span><br>Vincent van Gogh</span>
                </div>
            </div>

CSS: CSS:

.head-top {
  width: 90%;
  height: 15%;
  position: relative;
 }
.center {
  background: rgba(0, 0, 0);
  text-align: center;
  position: absolute;
  color: #000000;
  bottom: 0;
  right: 0;
  left: 0;
  top: 0;
  cursor: pointer;
}
.middle {
  position: absolute;
  margin-top: -6em;
  right: 0;
  left: 0;
  top: 50%;
}

Click Events: 点击事件:

 $('li.content0').hide();
  $('ul.toggle-menu').delegate('li.toggle', 'click', function () {
        $(this).next().toggle('fast').siblings('.content0').hide('fast');
    });

EDIT: CSS for buttons 编辑:按钮的CSS

/* Login, Sign Up Buttons Start Here */ / *登录,注册按钮从这里开始* /

@import url(http://fonts.googleapis.com/css?family=Montserrat:400,700);
#b1, 
#b2 {
  position: relative;
  padding: 14px 0;
  border: 2px #000000 solid;
  color: #000000;
  cursor: pointer;
  font-family: "Montserrat", "helvetica neue", helvetica, arial, sans-serif;
  font-size: .9em;
  text-transform: uppercase;
  transition: color 0.4s, background-color 0.4s;
  -webkit-border-radius: 2px;
  -moz-border-radius: 2px;
  border-radius: 2px;
  display: inline-block;
  vertical-align: middle;
  line-height: 1em;
  outline: none;
  text-align: center;
  text-decoration: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  width: 210px;
  top: 50%;
  left: 50%;
  margin: 0 -105px;
  width: 210px;
  pointer-events: none;
}
#b1:hover,#b1:focus
#b2:hover,#b2:focus {
  transition: color 0.4s, background-color 0.4s; 
  color: white;
  text-decoration: none;
  background-color: #000000;
}
#b1 {
  position: absolute;
  top: 7%;
  left: 81%;
  cursor: pointer;
}
#b2 {
  position: absolute;
  top: 7%;
  left: 100%;
  cursor: pointer;
}
/* Buttons End Here */

Your .center element covered the whole head-top element. 您的.center元素覆盖了整个head-top元素。 Lets find the other way of making the CSS with what you try to archive, for fix, remove and left the follow: 让我们找到用您尝试归档的内容制作CSS的另一种方法,以进行修复,删除并保留以下内容:

.center {
  background: rgba(0, 0, 0);
  text-align: center;
  color: #000000;
  cursor: pointer;
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM