[英]HTML/CSS- how to align part of a cell to the left, and part to the right?
[英]Materialize CSS- Align navbar to the far right
我正在使用實體化CSS並創建了Nav,但想將其向右移動一點而不影響徽標的位置。 請參閱下面的當前圖像;
我當前的代碼:
< div class="navbar-fixed">
<nav class="white" role="navigation" id="top-nav">
<div class="nav-wrapper container">
<a id = "logo-container" href="#" class="brand-logo"><img src = "img/DataNavSmaller.png" ></ a >
< ul class="right hide-on-med-and-down">
<li><a href = "#" class="active">Home</a></li>
<li><a href = "#" > Who We Are</a></li>
<li><a href = "#" > What We Do</a></li>
<li><a href = "#" > Contact Us</a></li>
</ul>
<ul id = "nav-mobile" class="sidenav">
<li><a href = "#" > Navbar Link</a></li>
</ul>
<a href = "#" data-target="nav-mobile" class="sidenav-trigger"><i class="material-icons">menu</i></a>
</div>
</nav>
</div>
CSS:
nav.brand - logo {
margin - left: -60px;
padding - top: 4px;
}
nav.right {
padding - top: 10px;
}
nav ul a{
color: black;
font - size:20px;
}
我該如何實現以上目標?
怎么樣
導航.right {float:right; }
您可以使用CSS屬性position: fixed; top: 10px; right: 5px;
設置導航欄的右側position: fixed; top: 10px; right: 5px;
position: fixed; top: 10px; right: 5px;
。 position: fixed
會使元素保持在原位。 top
指定元素到top
的距離, right
指定元素到right
的距離(這些屬性僅在設置display
屬性時有效)。
.navbar-fixed{ position: fixed; top: 0; left: 0; right: 0; height: 50px; background-color: #BEBEBE; } .logo{ margin: 10px 10px 10px 15px; background: red; padding: 5px; background: linear-gradient(red, yellow, green); width: 60px; height: 25px; color: white; } .navbar-right{ position: fixed; top: 10px; right: 5px;/*pixels away from the right of the navbar*/ } .title{ display: inline-block; margin: 5px; }
<div class="navbar-fixed"> <div class="logo"> <!--<img src="something.png" alt="img"/>--> DataNav </div> <div class="navbar-right"> <div class="title"> Home </div> <div class="title"> Who we are </div> <div class="title"> What we do </div> <div class="title"> Contact us </div> </div> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.