我无法弄清楚这个简单的任务。我需要将按钮放在左侧。
HTML
<body>
<nav class="navbar navbar-dark fixed-top bg-info flex-md-nowrap p-0">
<a class="navbar-brand col-md-2 mr-0" href="#">Web name</a>
<button class="btn btn-primary btn-sm float-left">
<span data-feather="toggle-left"></span>
</button>
<span class="text-nowrap" style="color:white; margin-right:20px;"><span data-feather="user"></span>username</span>
</nav>
...
</body>
答案 0 :(得分:2)
将float-left
替换为mr-auto
以获取自动右边距。这将使按钮向后推。
<nav class="navbar navbar-dark fixed-top bg-info flex-md-nowrap p-0">
<a class="navbar-brand col-md-2 mr-0" href="#">Web name</a>
<button class="btn btn-primary btn-sm mr-auto">
<span data-feather="toggle-left"></span>
</button>
<span class="text-nowrap" style="color:white; margin-right:20px;"><span data-feather="user"></span>username</span>
</nav>
https://www.codeply.com/go/SQD3e4YHMY
相关:Bootstrap NavBar with left, center or right aligned items