如何使用HTML和css將這個“標題”移動到標記的位置。導航鏈接的中心。 請盡量像我一樣詳細說明;我只是一個初學者,這是django網站。提前感謝:)【! 我發現移動東西和做事情有點復雜,所以請讓我出去,這個社區對取得進展很有幫助。圖像已給出
HTML代碼:
{% load static %}
<link rel="stylesheet" href="{% static "portofolio/css/style.css" %}">
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
{% block content %}
<nav>
<div class="logo">
<h4>TITLE</h4>
</div>
<ul class="nav-links">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
{% endblock %}
CSS代碼:
*{ margin: 0;
padding: 0;
box-sizing: content-box;
}
p {
;
}
.nav-link{
font-family: 'Poppins', sans-serif;
}
nav {
display: flex;
justify-content: center;
align-items: baseline;
min-height: 8vh;
padding-top: 100px;
height: 100px;
background-color: black;
}
.logo {
color: rgb(226,226,226);
text-transform: uppercase;
letter-spacing: 5px;
font-size: 20px;
font-family: 'Poppins', sans-serif;;
}
.nav-links {
display: flex;
justify-content: space-around;
width: 30%;
}
.nav-links li {
list-style: none;
}
.nav-links a {
color: rgb(226,226,226);
text-decoration: none;
letter-spacing: 3px;
font-weight: bold;
font-size: 14px;
font-family: 'Poppins', sans-serif;
}
我清理了你的代碼以獲得更好的響應,希望對你有用。
* {
margin: 0;
padding: 0;
}
.nav-link {
font-family: 'Poppins', sans-serif;
}
nav {
min-height: 8vh;
padding-top: 100px;
height: 100px;
background-color: black;
width: 100%;
justify-content: center;
display: flex;
flex-direction: column;
}
.logo {
color: rgb(226, 226, 226);
text-transform: uppercase;
letter-spacing: 5px;
font-size: 20px;
font-family: 'Poppins', sans-serif;
text-align: center;
border: 1px solid red;
}
.nav-links {
display: flex;
justify-content: center;
width: 100%;
border: 1px solid yellow;
}
.nav-links li {
list-style: none;
border: 1px solid red;
margin: 5px;
padding: 10px;
text-align: center;
display: inline-block;
}
.nav-links a {
color: rgb(226, 226, 226);
text-decoration: none;
letter-spacing: 3px;
font-weight: bold;
font-size: 14px;
font-family: 'Poppins', sans-serif;
}
<link rel="stylesheet" href="{% static " portofolio/css/style.css>
<link rel="stylesheet">
<nav>
<div class="logo">
<h4>TITLE</h4>
</div>
<ul class="nav-links">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
上一篇span元素中的內聯布局
下一篇c 的json方法嗎