为什么Bootstrap按钮在放入DIV时会停止工作



我有两个按钮,我试图将它们放在页面的中心。最简单的方法是将它们放在div中,但当我这样做时,按钮会变得没有响应。它们失去了悬停和单击功能。我尝试过更改背景div、包装器div和按钮的z索引,但没有起到任何作用。这是我的代码:

<!DOCTYPE html>
<html>
{% load staticfiles %}
{% load rest_framework %}
<head>
<link type="text/css" rel="stylesheet" href="https://bootswatch.com/yeti/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="{% static 'app/index.css' %}">
<title>Home</title>
</head>
<body>
{% if messages %}
{% for message in messages %}
{{ message }}
{%endfor%}
{%endif%}
{% verbatim %}
<div id="background"></div>
<div id="wrapper">
<a href="/signup" class="btn btn-primary">Sign Up Now!</a>
<a href="" class="btn btn-info">Learn More</a>
</div>
<div id="topwrapper">
<a href="/login">
<div id="login">Log in</div>
</a>
<a href="/signup">
<div id="signup">Sign Up</div>
</a>
</div>
<h1>Catchy Interesting Hook.</h1>
<p>Lorem ipsum stuff blah blah blah</p>
<h2>What is this website?</h2>
{% endverbatim %}
</body>
</html>

topwrapperdiv中的链接可以工作,但它们不是引导按钮。注意:{% %}中有趣的代码是Django的东西,我安装了各种Django引导插件,所以这可能就是我的按钮的问题所在?但我是django的新手,所以我真的不知道该怎么调查。然后我的CSS是:

#background {
background-color: #5f6273;
height: 500px;
position: absolute;
padding: 0px 0px 0px 0px;
border-width: 0px;
margin: 0px 0px 0px 0px;
top: 0px;
left: 0px;
right: 0px;
z-index: -30;
}
#wrapper {
text-align: center;
margin: 0 auto;
margin-top: 300px;
background: none;
width: 320px;
display: inline;
z-index: -1;
}
#topwrapper {
width: 300px;
display: inline;
background-color: none;
margin: auto;
height: 100px;
margin-right: 0;
z-index: 0;
padding: 20px;
}
#login {
border-radius: 2px;
border-color: #ffffff;
height: 30px;
width: 140px;
left: 30%;
margin: auto;
padding-top: 10px;
text-align: center;
font-family: sans-serif;
color: #ffffff;
z-index: 30;
}
#signup {
left: -50%;
font-family: sans-serif;
color: #ffffff;
height: 30px;
width: 70px;
z-index: 30;
margin: auto;
}
.btn-primary {
float: left;
margin-left: auto;
z-index: 31;
}
.btn-info {
float: right;
margin-right: auto;
z-index: 31;
}
h1 {
font-family: sans-serif;
text-align: center;
color: #ffffff;
padding-top: 160px;
}
h2 {
font-family: sans-serif;
text-align: center;
color: #000000;
padding-top: 275px;
z-index: 30;
}
p {
font-family: serif;
text-align: center;
color: #ffffff;
padding-top: 0px;
}

我保持了您所有的css不变,但在删除django内容的同时,在html中只做了一点更改。。。链接正在工作。尝试将您的django代码添加到此:

<body>
<div id="background"></div>
<div id="wrapper">
<button class="btn btn-primary"><a href="/signup">Sign Up Now!</a></button>
<button class="btn btn-primary"><a href="/login">Learn More</a></button>
</div>
<div id="topwrapper">
<a href="/login">
<div id="login">Log in</div>
</a>
<a href="/signup">
<div id="signup">Sign Up</div>
</a>
</div>
<h1>Catchy Interesting Hook.</h1>
<p>Lorem ipsum stuff blah blah blah</p>
<h2>What is this website?</h2>
</body>

最新更新