javascript - 如何在引导程序中为我的顶部导航栏添加徽标容器和水平分隔线?
问题描述
我正在尝试创建一个顶部导航栏,其左侧有一个颜色为 #1 的徽标作为背景。然后,它被一个灰色的水平分隔线分隔,然后你有颜色#2,应用程序名称位于分隔线旁边。我试图做到这一点,但我只能获得徽标和单个顶部导航背景颜色。我无法找到划分导航栏的方法。
HTML:
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img alt="My Logo" src="my-logo-png-transparent.png">
</a>
</div>
</div>
</nav>
</body>
<script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
crossorigin="anonymous"></script>
<script src="dashboard_static/dist/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.0.12/dist/js/select2.min.js"></script>
<script src="https://unpkg.com/feather-icons/dist/feather.min.js"></script>
</html>
CSS:
nav {
background: #282829;
border-bottom: 2px solid #999999;;
}
img {
height: 27.5px;
width: 23.6px;
}
解决方案
你的意思是这样的:
索引.html
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header nav-logo">
<a class="navbar-brand" href="#">
<img alt="My Logo" src="https://via.placeholder.com/30/">
</a>
<span>NAME</span>
</div>
</div>
</nav>
样式.css
.navbar {
background: blue;
border-bottom: 2px solid #999999;
padding: 0px;
}
.container-fluid{
padding: 0px;
}
.navbar-brand {
background: red;
border-right: 2px solid grey;
padding: 20px 30px;
}
推荐阅读
- javascript - 加载前如何在前端使用javascript获取外部图像的文件大小
- c++ - C ++:读取文件时如何跳转到下一个立即行?
- python - 为什么我的程序最后打印 None ?
- javascript - 如何在下拉菜单中有隐藏选项?
- marklogic - Marklogic 数据中心升级问题
- java - 是否可以对 ActiveMQ 主题进行分区,以便它使用消息中的键来确定将消息发布到哪个分区?
- python-3.x - 带有屏幕点击问题的无限while循环
- python - 无法安装 jupyter(Python 3.9.0、macos 11)
- firebase - 如何从 Firestore 中检索多个值?
- redux - 关于 react-redux npm 包 'peerDependencies' 的问题