导航栏内有一个按钮,但 btn 不属于导航栏的 div class
A button is inside the navigation bar, but the btn doesnt belong in the div class of the nav bar
所以我做了一个与此类似的post,因为我没有得到准确的答案并且不理解说明。所以再次请求大家的支持
有几个关于我的导航栏的问题我无法修复。其中之一是导航栏内的按钮,但它甚至不属于 div
class。
导航栏
第二个问题是我无法将 logo/text [SINUS] 和链接排成一行。
任何帮助将不胜感激!
/*====================
The CSS File
Section 1:
Buttons
=====================*/
button {
background-color: #358cf0;
border: none;
border-radius: 18px;
text-align: center;
text-decoration: none;
opacity: 0.8;
font-size: 14px;
color: rgb(255, 255, 255);
padding: 12px 48px;
transition: 0.3s;
outline: none;
}
button:hover {
opacity: 1;
}
ul li {
display: inline-block;
padding: 10px;
font-size: 20px;
font-family: raleway;
}
ul li:hover {
color: orange;
}
/*====================
The CSS File
Section 2:
Alerts
=====================*/
.container {
position: fixed;
top: 74%;
right: 0;
left: 77%;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
font-family: basic;
}
.modal {
width: 40%;
min-width: 20rem;
background-color: #ffffff;
border-radius: 12px;
}
.modal-header {
display: flex;
align-items: center;
border-top-left-radius: 12px;
border-top-right-radius: 12px;
background-color: #358cf0;
padding: 8px 10px;
color: #fff;
font-size: 110%;
font-weight: 600;
font-family: basic;
}
.modal-content {
padding: 1rem;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
.modal-footer {
text-align: center;
}
/*====================
The CSS File
Section 3:
Body etc.
=====================*/
body {
background-color: #252036;
}
#navigation-container {
width: 1200px;
margin: 0 auto;
height: 70%;
}
.navigation-bar {
background-color: #1c172c;
position: fixed;
width: 100%;
left: 0;
top: 0;
text-align: right;
}
.navigation-bar ul {
padding: 0px;
margin: 0px;
text-align: right;
display: inline-block;
vertical-align: top;
}
.navigation-bar li {
list-style-type: none;
padding: 0px;
display: inline;
text-align: right;
}
.navigation-bar li a {
color: black;
font-size: 16px;
font-family: basic;
text-decoration: none;
line-height: 70px;
padding: 5px 15px;
opacity: 0.7;
}
#menu {
float: right;
}
/*====================
The CSS File
Section 4:
Text
=====================*/
@font-face {
font-family: basic;
src: url(Helmet-Regular.ttf);
}
h1 {
font-family: basic;
color: white;
font-size: 390%;
text-align: left;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="sccp.css">
<title>Sinus - 【Home】</title>
<link rel="icon" href="titl.ico">
<link rel="apple-touch-icon" href="titl.ico" />
</head>
<body>
<div class="navigation-bar">
<div id="navigation-container">
<h1>SINUS</h1>
<ul>
<li><a href="#">Home</a></li>
</ul>
</div>
</div>
<button>Download</button>
<div class="container" role="alert">
<div class="modal">
<div class="modal-header">
UPDATE! Sinus 1.0v
</div>
<div class="modal-content">
Here new stuff go gogogo
<br><a href="#">Read more...</a>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</body>
</html>
要对齐徽标和链接,请在 #navigation-container 上使用 flex:
#navigation-container {
display: flex;
justify-content: space-between;
align-items: center;
}
justify-content: space-between 将在内容之间放置最大 space - 在这种情况下,您的徽标和包含链接的 ul。 align-items:center 将它们垂直排列。
https://codepen.io/doughballs/pen/RwPrYoX
不确定您的按钮有什么问题,但是因为您的导航有 position:fixed,它被从页面流中删除,所以按钮没有 'know' 它是那里。如果你想让它位于导航下方,你需要添加一个带有 margin-top 的容器来将它向下推。但我不确定你的问题是什么,澄清一下,我会修改代码笔。
所以我做了一个与此类似的post,因为我没有得到准确的答案并且不理解说明。所以再次请求大家的支持
有几个关于我的导航栏的问题我无法修复。其中之一是导航栏内的按钮,但它甚至不属于 div
class。
导航栏
第二个问题是我无法将 logo/text [SINUS] 和链接排成一行。 任何帮助将不胜感激!
/*====================
The CSS File
Section 1:
Buttons
=====================*/
button {
background-color: #358cf0;
border: none;
border-radius: 18px;
text-align: center;
text-decoration: none;
opacity: 0.8;
font-size: 14px;
color: rgb(255, 255, 255);
padding: 12px 48px;
transition: 0.3s;
outline: none;
}
button:hover {
opacity: 1;
}
ul li {
display: inline-block;
padding: 10px;
font-size: 20px;
font-family: raleway;
}
ul li:hover {
color: orange;
}
/*====================
The CSS File
Section 2:
Alerts
=====================*/
.container {
position: fixed;
top: 74%;
right: 0;
left: 77%;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
font-family: basic;
}
.modal {
width: 40%;
min-width: 20rem;
background-color: #ffffff;
border-radius: 12px;
}
.modal-header {
display: flex;
align-items: center;
border-top-left-radius: 12px;
border-top-right-radius: 12px;
background-color: #358cf0;
padding: 8px 10px;
color: #fff;
font-size: 110%;
font-weight: 600;
font-family: basic;
}
.modal-content {
padding: 1rem;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
.modal-footer {
text-align: center;
}
/*====================
The CSS File
Section 3:
Body etc.
=====================*/
body {
background-color: #252036;
}
#navigation-container {
width: 1200px;
margin: 0 auto;
height: 70%;
}
.navigation-bar {
background-color: #1c172c;
position: fixed;
width: 100%;
left: 0;
top: 0;
text-align: right;
}
.navigation-bar ul {
padding: 0px;
margin: 0px;
text-align: right;
display: inline-block;
vertical-align: top;
}
.navigation-bar li {
list-style-type: none;
padding: 0px;
display: inline;
text-align: right;
}
.navigation-bar li a {
color: black;
font-size: 16px;
font-family: basic;
text-decoration: none;
line-height: 70px;
padding: 5px 15px;
opacity: 0.7;
}
#menu {
float: right;
}
/*====================
The CSS File
Section 4:
Text
=====================*/
@font-face {
font-family: basic;
src: url(Helmet-Regular.ttf);
}
h1 {
font-family: basic;
color: white;
font-size: 390%;
text-align: left;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="sccp.css">
<title>Sinus - 【Home】</title>
<link rel="icon" href="titl.ico">
<link rel="apple-touch-icon" href="titl.ico" />
</head>
<body>
<div class="navigation-bar">
<div id="navigation-container">
<h1>SINUS</h1>
<ul>
<li><a href="#">Home</a></li>
</ul>
</div>
</div>
<button>Download</button>
<div class="container" role="alert">
<div class="modal">
<div class="modal-header">
UPDATE! Sinus 1.0v
</div>
<div class="modal-content">
Here new stuff go gogogo
<br><a href="#">Read more...</a>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</body>
</html>
要对齐徽标和链接,请在 #navigation-container 上使用 flex:
#navigation-container {
display: flex;
justify-content: space-between;
align-items: center;
}
justify-content: space-between 将在内容之间放置最大 space - 在这种情况下,您的徽标和包含链接的 ul。 align-items:center 将它们垂直排列。
https://codepen.io/doughballs/pen/RwPrYoX
不确定您的按钮有什么问题,但是因为您的导航有 position:fixed,它被从页面流中删除,所以按钮没有 'know' 它是那里。如果你想让它位于导航下方,你需要添加一个带有 margin-top 的容器来将它向下推。但我不确定你的问题是什么,澄清一下,我会修改代码笔。