我在左侧有一个带有欢迎问候语的导航栏,但是我想将我的退出功能移到右侧的另一侧。目前它坐在欢迎旁边。关于如何移动它的任何想法? 这是我一直在使用的代码。
<nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
<!--navbar settings-->
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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" href="index.html">Logout</a>-->
<?php //echo $_SESSION["staffname"];
if(isset($_SESSION["staffId"]) && $_SESSION["staffId"] != NULL)
{ ?> <a class="navbar-brand">
Welcome <?php echo $_SESSION["staffname"]; ?></a>
<a href="logout.php" class="navbar-brand"><strong>Logout</strong></a>
<?php
}
?>
</div>
</div>
</nav>
答案 0 :(得分:6)
我认为最好的方法是使用带有 .navbar-right 类的div作为注销链接容器:
<?php $isLoggedIn = (isset($_SESSION["staffId"]) && $_SESSION["staffId"] != NULL) ? true : false; ?>
<nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
<!--navbar settings-->
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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" href="index.html">Logout</a>-->
<?php if($isLoggedIn): ?>
<a class="navbar-brand">
Welcome <?php echo $_SESSION["staffname"]; ?>
</a>
<?php endif; ?>
</div>
<?php if($isLoggedIn): ?>
<div class="nav navbar-nav navbar-right">
<a href="logout.php" class="navbar-brand"><strong>Logout</strong></a>
</div>
<?php endif; ?>
</div>
</nav>
答案 1 :(得分:1)
将类拉出添加到元素中:
<a href="logout.php" class="navbar-brand pull-right"><strong>Logout</strong></a>
答案 2 :(得分:1)
您可以使用右拉类
<a href="logout.php" class="navbar-brand pull-right"><strong>Logout</strong></a>
或使用float: right;
<style>
#lout
{float: right;}
</style>
<nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
<!--navbar settings-->
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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" href="index.html">Logout</a>-->
<?php //echo $_SESSION["staffname"];
if(isset($_SESSION["staffId"]) && $_SESSION["staffId"] != NULL)
{ ?> <a class="navbar-brand">
Welcome <?php echo $_SESSION["staffname"]; ?></a>
<a id = "lout" href="logout.php" class="navbar-brand"><strong>Logout</strong></a>
<?php
}
?>
</div>
</div>
</nav>
答案 3 :(得分:0)
尝试在锚元素上使用右拉类:
<a href="logout.php" class="navbar-brand pull-right"><strong>Logout</strong></a>