在Bootstrap 中居中導航項目
在Bootstrap 4 中,可以使用Flexbox 和邊距實用程式來對齊導航項目(連結項目)。
Bootstrap 4 Alpha 6 和稍後
在Bootstrap 4 alpha 6 及更高版本中將品牌和連結居中:
<nav class="navbar navbar-toggleable-md navbar-light bg-faded"> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="d-md-flex d-block flex-row mx-md-auto mx-0"> <a class="navbar-brand" href="#">Navbar</a> <div class="collapse navbar-collapse mr-auto">
Bootstrap 4.1
對於Bootstrap 4.1:<nav class="navbar navbar-toggleable-md navbar-light bg-faded"> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse">
在視口中精確定位連結
要將連結在視口中精確定位連結<nav class="navbar navbar-toggleable-md navbar-light bg-faded"> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="navbar-nav">
以上是如何在 Bootstrap 4 中居中導航專案?的詳細內容。更多資訊請關注PHP中文網其他相關文章!