gpt4 book ai didi

css - 导航栏标题没有移动到中心

转载 作者:行者123 更新时间:2023-11-28 02:40:16 25 4
gpt4 key购买 nike

出于某种原因,我在导航栏中的标题没有像我想要的那样移动到中心。我尝试使用填充、文本对齐和使用正确的功能都不起作用。谁能帮我?我尝试在这里关注这个问题,但没有任何反应,bootstrap 3 - how do I place the brand in the center of the navbar?

这是完整的代码,很抱歉弄得一团糟:应用程序.blade.php

<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">

<title>{{ config('app.name', 'Laravel') }}</title>

<!-- Styles -->
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">


<!-- Collapsed Hamburger -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse" 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>
<html>
<head>
<title>SideBar Menu</title>
<link href="{{ asset('css/style.css') }}" rel="stylesheet">
</head>

<body>

<div id="sidebar">

<ul>
<li><a href="{{route('home')}}">Summary</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit User Information <span class="caret"></span></a>
<ul class="dropdown-menu forAnimate" role="menu">
<li><a href="{{ url('/edit') }}" style="color: red">Personal Information Edit</a></li>
</ul>
</li>

<div id="sidebar-btn">
<span></span>
<span></span>
<span></span>
</div>

</div>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>

$(document).ready(function(){
$('#sidebar-btn').click(function(){
$('#sidebar').toggleClass('visible');
});
});

</script>
</body>
</html>

<!-- Branding Image -->
<a class="navbar-brand" href="{{ url('/') }}" style="color: white">
{{ config('app.name', 'Laravel') }}
</a>
</div>

<div class="collapse navbar-collapse" id="app-navbar-collapse">
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav">

&nbsp;
</ul>
<div id="center-text">
<ul class="nav navbar-nav navbar-center" id="nav-center">
<li>
<h3>@yield('title')</h3>
</li>
</ul>
</div>


<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
@guest
<li><a href="{{ route('login') }}">Login</a></li>
<li><a href="{{ route('register') }}">Register</a></li>
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" aria-haspopup="true" style="background-color:blue" style="color:white">
<b>{{ Auth::user()->name }}</b> <span class="caret"></span>
</a>

<ul class="dropdown-menu" style="background-color: blue">
<li>
<a href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();" style="background-color: blue" style="color: white">
<b>Logout</b>
</a>

<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</li>
</ul>
</li>
@endguest
</ul>
</div>
</div>
</nav>

@yield('content')
</div>

<!-- Scripts -->
<script src="{{ asset('js/app.js') }}"></script>

</body>
</html>

css 样式我是这样用的:样式.css

body{
margin:0px;
padding:0px;
font-family:"Helvetica Neue", Helvetica, Arial;
}

#sidebar{
background:blue;
width:200px;
height:100%;
display:block;
position: fixed;

left:-200px;
top:0px;
transition:left 0.3s linear;
}

#sidebar.visible{
left:0px;
transition:left 0.3s linear;
}

ul{
margin:0px;
padding:0px;
list-style-type:none;
display:flex;
justify-content: center;
}

ul li{
list-style:none;
}


ul li a{
background:#0000FF;
color: white;
border-bottom:1px solid #111;
display:block;
width:180px;
padding:10px;
text-decoration: none;
}

#sidebar-btn{
display:inline-block;
vertical-align: middle;
width:20px;
height:15px;
cursor:pointer;
margin:20px;
position:absolute;
top:0px;
right:-60px;
}

#sidebar-btn span{
height:1px;
background: white;
margin-bottom:5px;
display:block;
}

#sidebar-btn span:nth-child(2){
width:75%;
}

#sidebar-btn span:nth-child(3){
width:50%;
}

#navbar-toggle collapsed{
background:#0000FF;

}

.navbar {background:#0000FF;}

nav.sidebar .navbar-nav .open .dropdown-menu>li>a:hover, nav.sidebar .navbar-nav .open .dropdown-menu>li>a:focus {
color: white;
background-color: transparent;
}

#center-text ul{
list-style-type:none;
display:flex;
justify-content: center;
}

最佳答案

这应该可行

ul{
list-style-type:none;
display:flex;
justify-content: center;
}
<ul class="nav navbar-nav navbar-center" id="nav-center">
<li><h3>Text</h3></li>
</ul>

关于css - 导航栏标题没有移动到中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47215100/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com