body {
background-color: rgb(30, 21, 120);
margin: 0;
padding: 0;
}
p {
color: white;
font-size: 20px;
display: inline;
padding: 20px;
}
div.package {
position: relative;
border: 4px solid white;
border-radius: 70px;
margin: 60px 0 60px 0;
background-color: rgb(37, 110, 194);
padding: 40px;
transition-duration: 0.4s;
}
p.package {
color: white;
padding-left: 3vw;
font-size: 2vw;
text-align: center;
}
div.package:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 35px 60px 0
rgba(0,0,0,0.19);
}
.purchase {
float: right;
width: 20vw;
height: 75px;
background-color: rgb(10,27,64);
color: white;
border-color: rgb(24,146,40);
position: relative;
bottom: 17px;
border-radius: 30px;
border-style: solid;
border-width: 5px;
transition-duration: 0.4s;
font-size: 2vw;
}
.purchase:hover {
z-index: 2;
background-color: rgb(116,164,242);
color: black;
width: 24vw;
}
.purchase_b {
display: none;
}
.navbar {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgb(10,10,10);
top: 0;
}
.navcont {
margin: 0;
position: relative;
float: left;
}
.navcont a {
margin: 0;
position: relative;
display: block;
color: white;
font-size: 20px;
text-align: center;
padding: 5vh 7vw;
text-decoration: none;
border-right: 1px solid rgb(50,50,50);
border-left: 1px solid rgb(50,50,50);
}
.navcont a:hover {
transition-duration: 0.3s;
background-color: rgb(30,30,30);
}
.navcont a:active {
background-color: rgb(9,194,36);
}
#navbarIMG {
margin: 0;
}
.sticky {
position: sticky;
position: -webkit-sticky;
top: 0;
}
@media screen and (max-width: 600px) {
.purchase_b {
position: absolute;
text-align: center;
display: block;
}
button.purchase {
width: 100%;
bottom: 10px;
}
p.package {
bottom: 100px;
font-size: 2.65vw;
}
.package {
height: 70px;
}
.purchase:hover {
background-color: rgb(116,164,242);
color: black;
width: 100%;
}
p {
font-size: 10px;
padding: 0;
}
.navcont a {
padding: 3vh 3vw;
}
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My site</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="sticky">
<ul class="navbar">
<li class="navcont"><a href="index.htm">Home</a></li>
<li class="navcont"><a href="#about">About</a></li>
<li class="navcont"><a href="#purchase">Purchase</a></li>
<li class="navcont" style="float: right;"><a href="#contact">Contact</a></li>
</ul>
</div>
<br>
<br>
<br>
<br class="purchase_b">
<br class="purchase_b">
<div class="package">
<p class="package">Recommended Package: Standard Package | Only $20 per month!</p>
<br class="purchase_b" />
<br class="purchase_b" />
<button value="Purchase" class="purchase" style="cursor: pointer;">Purchase</button>
</div>
<div class="package">
<p class="package">Popular Choice: Premium Package | Only $35 per month!</p>
<br class="purchase_b" />
<br class="purchase_b" />
<button value="Purchase" class="purchase" style="cursor: pointer;">Purchase</button>
</div>
</body>
</html>
因此,我目前在导航栏顶部出现了购买框和购买按钮的问题。我尝试使用Z-index,但是购买框和按钮的动画均停止工作。有什么办法可以使购买框和按钮显示在导航栏的后面?谢谢!
我向下滚动了一下,购买框移到了导航栏上。
答案 0 :(得分:1)
我在z-index:3
类中添加了.sticky
,请看下面的代码片段。
body {
background-color: rgb(30, 21, 120);
margin: 0;
padding: 0;
}
p {
color: white;
font-size: 20px;
display: inline;
padding: 20px;
}
div.package {
position: relative;
border: 4px solid white;
border-radius: 70px;
margin: 60px 0 60px 0;
background-color: rgb(37, 110, 194);
padding: 40px;
transition-duration: 0.4s;
}
p.package {
color: white;
padding-left: 3vw;
font-size: 2vw;
text-align: center;
}
div.package:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 35px 60px 0
rgba(0,0,0,0.19);
}
.purchase {
float: right;
width: 20vw;
height: 75px;
background-color: rgb(10,27,64);
color: white;
border-color: rgb(24,146,40);
position: relative;
bottom: 17px;
border-radius: 30px;
border-style: solid;
border-width: 5px;
transition-duration: 0.4s;
font-size: 2vw;
}
.purchase:hover {
z-index: 2;
background-color: rgb(116,164,242);
color: black;
width: 24vw;
}
.purchase_b {
display: none;
}
.navbar {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgb(10,10,10);
top: 0;
}
.navcont {
margin: 0;
position: relative;
float: left;
}
.navcont a {
margin: 0;
position: relative;
display: block;
color: white;
font-size: 20px;
text-align: center;
padding: 5vh 7vw;
text-decoration: none;
border-right: 1px solid rgb(50,50,50);
border-left: 1px solid rgb(50,50,50);
}
.navcont a:hover {
transition-duration: 0.3s;
background-color: rgb(30,30,30);
}
.navcont a:active {
background-color: rgb(9,194,36);
}
#navbarIMG {
margin: 0;
}
.sticky {
position: sticky;
position: -webkit-sticky;
top: 0;
z-index:3
}
@media screen and (max-width: 600px) {
.purchase_b {
position: absolute;
text-align: center;
display: block;
}
button.purchase {
width: 100%;
bottom: 10px;
}
p.package {
bottom: 100px;
font-size: 2.65vw;
}
.package {
height: 70px;
}
.purchase:hover {
background-color: rgb(116,164,242);
color: black;
width: 100%;
}
p {
font-size: 10px;
padding: 0;
}
.navcont a {
padding: 3vh 3vw;
}
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My site</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="sticky">
<ul class="navbar">
<li class="navcont"><a href="index.htm">Home</a></li>
<li class="navcont"><a href="#about">About</a></li>
<li class="navcont"><a href="#purchase">Purchase</a></li>
<li class="navcont" style="float: right;"><a href="#contact">Contact</a></li>
</ul>
</div>
<br>
<br>
<br>
<br class="purchase_b">
<br class="purchase_b">
<div class="package">
<p class="package">Recommended Package: Standard Package | Only $20 per month!</p>
<br class="purchase_b" />
<br class="purchase_b" />
<button value="Purchase" class="purchase" style="cursor: pointer;">Purchase</button>
</div>
<div class="package">
<p class="package">Popular Choice: Premium Package | Only $35 per month!</p>
<br class="purchase_b" />
<br class="purchase_b" />
<button value="Purchase" class="purchase" style="cursor: pointer;">Purchase</button>
</div>
</body>
</html>
答案 1 :(得分:0)
我已经更改了CSS代码中的 [HttpGet]
[Route("google-login")]
public IActionResult GoogleLogin(string returnUrl = null)
{
var authProperties = new Microsoft.AspNetCore.Authentication.AuthenticationProperties
{
RedirectUri = string.IsNullOrEmpty(returnUrl) ? "account/profile" : returnUrl,
IsPersistent = true
};
return Challenge(authProperties, new string[] { "google" });
}
类。
pelusoftcamerawebapp.azurewebsites.net
sticky
.sticky {
position: fixed;
z-index: 5;
width: 100%;
}