我是编码和堆栈溢出的新手,下面提到的是代码,我试图在缩小屏幕尺寸时将两个图标放在与品牌徽标和菜单相同的行中。
下面提到的是代码。
<nav class="navbar navbar-default navbar-justified">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed " data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand logo" href="#"><img src="images/zigsaw.png" class="img-responsive" alt="logo"></a>
</div>
<div class="nav navbar-nav navbar-center navbar-header">
<ul class="list-inline">
<li><a href="#" class="badge badgeq"><i class="fa fa-bell fa-2x" aria-hidden="true"></i></a></li>
<li><a href="#" class="badge badgeq"><i class="fa fa-comment fa-2x " aria-hidden="true"></i></a></li>
</ul>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="#">Link <span class="sr-only">(current)</span></a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
CSS:
.badgeq {
display: flex;
min-width: 10px;
padding: 3px 7px;
font-size: 12px;
font-weight: 700;
line-height: 1;
color: #35BBE6;
text-align: center;
white-space: nowrap;
vertical-align: middle;
background-color: transparent;
border-radius: 10px;
}
.badge:after {
content: "100";
position: relative;
background: rgba(0,0,255,1);
height: 2rem;
top: 0rem;
right: 0.5rem;
width: 2rem;
text-align: -webkit-center;
line-height: 2rem;
font-size: 1rem;
border-radius: 50%;
color: white;
border: 1px solid blue;
}
@media (min-width: 768px) {
.navbar-nav.navbar-center {
position: absolute;
left: 45%;
transform: translatex(-50%);
margin-top: 10px;
}
}
答案 0 :(得分:0)
Flexbox定义Flex项目在Flex容器中的布局方式。 Flex项目沿柔性线定位在柔性容器内。默认情况下,每个Flex容器只有一个弹性线。所以,你可以试试波纹管结构:
<!DOCTYPE html>
<html>
<head>
<style>
.flex-container {
display: -webkit-flex;
display: flex;
width: 400px;
height: 250px;
background-color: lightgrey;
}
.flex-item {
background-color: cornflowerblue;
width: 100px;
height: 100px;
margin: 10px;
}
</style>
</head>
<body>
<div class="flex-container">
<div class="flex-item">flex item 1</div>
<div class="flex-item">flex item 2</div>
<div class="flex-item">flex item 3</div>
</div>
</body>
</html>