Bootstrap Navbar切换器和菜单定位

时间:2018-07-12 15:08:47

标签: html css bootstrap-4

我在CodePen https://codepen.io/anon/pen/qydVKY#anon-signup上有此页面,我试图在其中将切换开关图标重新定位到右侧。但是,看来navbar-toggler-right不起作用,或者我使用的方式不正确。

此外,我想重新定位单击切换按钮时显示的菜单。我一天中大部分时间都在尝试此操作,但无法弄清楚。

HTML和CSS如下:

body {
	padding-top: 1em;
}

@media (min-width: 1200px) {
	.container {
		max-width: 1200px;
	}
}

#logo {
	float: left;
}

.cs-navbar {
	margin-left: 40px;
	font-family: 'Cairo', sans-serif;
	font-size: 20px;
}
<html lang="en">
	<head>
		<!-- Required meta tags -->
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

		<!-- Bootstrap CSS -->
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
		<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
		<link href="https://fonts.googleapis.com/css?family=Cairo" rel="stylesheet">
		<link rel="stylesheet" href="css/bootstrap-custom.css">

		<title>My Site</title>
	</head>
	<body>
		<header class="container">
			<div id="logo">
				<object type="image/svg+xml" data="img/logo.svg" height="60px">
						Your browser does not support SVG
				</object>
			</div>
			
			<nav class="navbar navbar-expand-lg navbar-light">
				<!-- <a class="navbar-brand" href="#">Expand at md</a> -->
				<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false" aria-label="Toggle navigation">
					<span class="navbar-toggler-icon"></span>
				</button>
				<div class="collapse navbar-collapse" id="main-navbar">
					<ul class="navbar-nav mr-auto cs-navbar">
						<li class="nav-item active">
							<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
						</li>
						<li class="nav-item dropdown">
							<a class="nav-link dropdown-toggle" href="#" id="dropdown04" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Chapters</a>
							<div class="dropdown-menu" aria-labelledby="dropdown04">
								<a class="dropdown-item" href="#">Chapter 1</a>
								<a class="dropdown-item" href="#">Chapter 2</a>
								<a class="dropdown-item" href="#">Chapter 3</a>
								<a class="dropdown-item" href="#">Chapter 4</a>
								<a class="dropdown-item" href="#">Chapter 5</a>
								<a class="dropdown-item" href="#">Chapter 6</a>
							</div>
						</li>						
						<li class="nav-item">
							<a class="nav-link" href="#">Bookmarks</a>
						</li>
						<li class="nav-item">
							<a class="nav-link" href="#">Table of Contents</a>
						</li>
						<li class="nav-item">
							<a class="nav-link" href="#">Index</a>
						</li>
					</ul>
					<!-- <form class="form-inline my-2 my-md-0">
						<input class="form-control" type="text" placeholder="Search">
					</form> -->
				</div>
			</nav>
		</header>
		<!-- Optional JavaScript -->
		<!-- jQuery first, then Popper.js, then Bootstrap JS -->
		<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
		<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
	</body>
</html>

0 个答案:

没有答案