我正在用 html 和 CSS 构建一个静态网站(JS,如果我真的需要它),并且在导航栏中我希望中间有一个徽标,稍微下降一点(例如。https: //usiscreamingeagles.com/)。这是响应式 topnav 上的圆形徽标。我可以获得一些帮助来向下延伸吗?
以下是现有代码。现在,它只是按照图像的大小扩展导航栏,就像您期望的那样:
.topnav {
overflow: hidden;
background-color: rgb(9, 120, 128);
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.active {
background-color: #04AA6D;
color: white;
}
.topnav .icon {
display: none;
}
.topnav a:hover {
background-color: #555;
color: white;
}
/* If screen is less than 600px, create hamburger*/
@media screen and (max-width: 600px) {
.topnav a:not(:first-child) {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
@media screen and (max-width: 600px) {
.topnav.responsive {
position: relative;
}
.topnav.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>
<!--NAVIGATION BAR-->
<div class="topnav" id="myTopnav">
<a href="#schedule">Schedule</a>
<a href="#home">
<img src="files\img.jpg">
</a>
<a href="#contact">Contact</a>
<a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">☰</a>
</div>
<script>
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
</body>
类似的事情:
.imgClassName {
position: fixed;
top: 40px;
}