st7th st7th - 2 months ago 39
CSS Question

Bootstrap 4 branding element pushing navbar to a new line

I want to have a fixed top navbar like this with (Because its one list item I dont need the hamburger toggleable feature)

However the navbar brand element pushed the navigation to a new row. I tried the pull-right class and a justify-content-end but neighter of them worked.

It looks like this.

My code so far is like this. Thank you for your help!



body{
padding-top: 130px;
}

.navbar{
padding-top: 1rem;
padding-bottom: 2rem;
height: 130px;
}

.bg-faded{
background-color: white;
}

.navbar-brand{
font-family: 'Lato', sans-serif;
font-size: 2.20rem;
color: rgba(0, 0, 0, 1);
font-weight: 900;
}


.nav-item a{
font-family: 'Lato', sans-serif;
font-size: 0.8rem;
color: rgba(0, 0, 0, 1);
font-weight: 900;
text-transform: uppercase;
}

.jumbotron{
margin-bottom: 0;
}

#week1{
background-image: url('../img/week1.jpg');
background-repeat: no-repeat;
background-position: center;
background-size:100%;
}

<!DOCTYPE html>
<html lang="en">
<head>
<title>52 Weeks of Portrait</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="css/my.css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,900|Merriweather" rel="stylesheet">
</head>
<body>
<!-- Navigation Bar -->
<nav class="navbar fixed-top navbar-light bg-faded">
<a class="navbar-brand" href="index.html">52 Weeks of Portrait</a>
<ul class="nav navbar-nav justify-content-end">
<li class="nav-item">
<a class="nav-link" href="#">About + Rules</a>
</li>
</ul>
</nav>
<div class="jumbotron jumbotron-fluid" id="week1">
<div class="container">
<h1 class="display-3">Week One</h1>
<p class="lead"></p>
</div>
</div>




<!-- jQuery first, then Tether, then Bootstrap JS. -->
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</body>
</html>




Answer Source

Wrap your brand to div with class 'navbar-header' and use:

float:left

and

float:right

to .navbar-nav

Fiddle: https://jsfiddle.net/06fv6ona/1/