Bulma navbar with two rows - css

What's the best approach to recreate this in bulma.io? Including responsivness, hamburger etc.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-fixed-top">
<div class="container">
<div class="row navbar-first-row">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#navbar-main-collapse">
<span class="glyphicon glyphicon-menu-hamburger"></span>
<span class="sr-only">Toggle navigation</span>
</button>
<div class="navbar-right navbar-text hidden-xs">
Logo
</div>
<h1 class="h4 navbar-text">Really long application title</h1>
</div>
<div class="row navbar-second-row">
<div class="navbar-right navbar-text hidden-xs">Logged User</div>
<div class="collapse navbar-collapse" id="navbar-main-collapse">
<ul class="nav navbar-nav">
<li class="active">Item 1</li>
<li>Item 2</li>
<li>Item 2</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>
</div>
</div>
</nav>
--- tl;dr ---
I recently moved to Vue.js on frontend, which involved massive changes in my workflow. I was also thinking about trying to switch from Bootstrap3 to something more cleaner and tried Bulma. It was really pleasuring experience until I wanted to do something just a little bit out of ordinary. In my case it was two-lines navbar. After an hour of trying I quickly switched back to Bs3.
The main advantage of using bootstrap is that thousands of weirdos who wanted to achieve all kinds of crazy already asked dozens of silly questions. Most of them were answered by the patient community and are now available to the public. Bulma unfortunately doesn't really have this yet.
I feel that at least 70% of being a programmer nowdays mean to google-around stackoverflow anyway. Ability to research quickly to the subject is essential. I don't have the time to explore everything for myself, I have a family to feed and my clients don't give a damn about which framework I use. But at least I decided to ask. May be someone will face similar challenge in the future. Cheers.

There are likely many ways to do this. Here is one approach:
Create your menu as described in the documentation
Then...
HTML
Add the 'Application Title' as the first-child of navbar-brand.
Add the is-hidden-touch modifier to the navbar-item containing the logo. This will hide it on mobile and tablet devices.
The 'logged in user' content can be added to navbar-end.
CSS
We need navbar-brand to occupy its own 'row'. To do this, update its width to 100%.
Then, add the justify-content property to navbar-brand to space its contents evenly.
To ensure that navbar-menu moves to a new 'row', you must add the flex-wrap property to the navbar.
fiddle
.navbar-brand {
width: 100%;
}
.navbar {
flex-wrap: wrap;
}
.navbar-brand {
justify-content: space-between;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.1/css/bulma.min.css" rel="stylesheet"/>
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item">Really Long Application Title</a>
<a class="navbar-item is-hidden-touch">
<img src="https://bulma.io/images/bulma-logo.png" alt="Bulma" width="112" height="28">
</a>
<button class="button navbar-burger" data-target="navMenu">
<span></span>
<span></span>
<span></span>
</button>
</div>
<div class="navbar-menu" id="navMenu">
<div class="navbar-start">
<a class="navbar-item">Item 1</a>
<a class="navbar-item">Item 2</a>
<a class="navbar-item">Item 3</a>
<a class="navbar-item">Item 4</a>
<a class="navbar-item">Item 5</a>
</div>
<div class="navbar-end">
<a class="navbar-item">Logged in</a>
</div>
</div>
</nav>

Related

Bootstrap 4 Navbar and content fill height flexbox

I have to create a layout in which a content grid has to be on the full remaining page, but the layout has also a navigation bar.
In order to do this I decided to place the navigation bar in a flex container and the content in a row with height 100%. I need the content to fill the rest of the remaining space. The menu is dynamic so I can not know how the height of the navigation bar is.
However on smaller screens the navigation bar does not resize correctly. If the menu is expanded the menu is overlayed with the content.
<div class="container-fluid h-100 d-flex flex-column">
<nav class="navbar navbar-expand-sm s-navbar">
...
</nav>
<div class="row h-100">
...// content presented here
</div>
</div>
You can see it here
https://jsfiddle.net/ej9fd368/8/ that the last menu item is cut because of the yellow content.
My requirement is that the content should fill the rest of the page.
Instead of using h-100 on the yellow content area, add an extra CSS class to make it flex-grow:1 in height...
.flex-fill {
flex:1 1 auto;
}
https://www.codeply.com/go/xBAMfbHqbN
<div class="container-fluid h-100 d-flex flex-column">
<nav class="navbar navbar-expand-sm s-navbar">
<a class="brand navbar-brand" href="/">Brand</a>
<button class="navbar-toggler s-btn-hamburger order-first s-color-icons" aria-expanded="true" aria-controls="navbar-test" aria-label="Toggle navigation" type="button" data-target="#navbar-test" data-toggle="collapse">
<span class="navbar-toggler-icon k-icon k-icon-md k-i-hamburger"></span>
</button>
<div class="navbar-collapse s-menu-content collapse show" id="navbar-test">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="dropdown1" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown">Menu Item</a>
<div class="dropdown-menu" aria-labelledby="dropdown1">
<a class="dropdown-item" href="/Device">Sub menu</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="/Test">Test</a>
</li>
</ul>
</div>
</nav>
<div class="row flex-fill">
<main class="col" style="background-color: yellow"></main>
</div>
</div>
Note: The flex-fill utility class will be included in the next Bootstrap 4.1 release:
https://github.com/twbs/bootstrap/commit/2137d61eacbd962ea41e16a492da8b1d1597d3d9
(Updated Bootstrap 4.1 demo)
Related question: Bootstrap 4: How to make the row stretch remaining height?

Bootstrap navbar-fixed-top is not working

I am trying to create a page with a fixed navigation bar at the top of the page. What I need is something like this.
As we can see in above linked page, the content of the page starts after giving priority to the navbar. But in my case, the content starts right from the beginning of the page. It is like the navbar is placed on top of the other content.
You can see the JsFiddle demo here.
In the demo page, I have not added anything new. It contains the source of the page which is linked earlier in this question.
this is my navbar and the other div which have been put inside the body section of the page.
<!-- Fixed navbar -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
.......
</button>
<a class="navbar-brand" href="#">Bootstrap theme</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
.......
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
<div class="container theme-showcase" role="main">
.....
</div>
Why can't I see my page as needed. Have I missed something in my code?
In the Bootstrap template they have this css code
body {
padding-top: 70px;
padding-bottom: 30px;
}
and this code is used in theme.css file which is not included in your html.
You can resolve this by adding only the code above in your CSS code
or you can link to theme.css file in your HTML code
Add CSS:
body {
padding-top: 70px;
}
You can see this by inspecting the element here. It do exist in css.
https://getbootstrap.com/examples/navbar-fixed-top/

Bootstrap Toggle Open Menu not spanning 100% width of screen

I'm having a bit of a problem with the Bootstrap nav I've placed on a website I'm making.
When collapsed on smaller screens, the drop down navigation menu doesn't span 100% of the screen - It looks as if there's a 1px gap on either side of the menu and I can't seem to figure out how to fix this.
** EDIT **
Due to bad markup in my original post - I've updated this (still having probelems, but this represents my problem better) at JSFIDDLE
<div class="navbar navbar-custom">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation">
<span class="fa fa-bars fa-2x"></span> Menu</button>
<span class="logo"> Logo</span>
</div>
<div class="collapse navbar-collapse" id="navigation">
<ul class="nav navbar-nav navbar-right">
<li>Book A Repair </li>
<li>About </li>
<li>How it Works </li>
<li>Testimonals </li>
<li>Contact </li>
</ul>
</div>
</div>
It's happening because of the Bootstrap margin on the .navbar-collapse.. which is a negative margin of 15px. Just move it out a pixel on each side:
.navbar-custom .container >.navbar-collapse {
margin-right: -16px;
margin-left: -16px;
}
Bootply

Trouble with nav-justified in Bootstrap 3.0 on responsive devices

I am using the Bootstrap 3.0 framework and Modern Business theme (http://startbootstrap.com/modern-business). When using the default Modern Business nav settings, the main menu dropdowns work brilliantly as they should on mobile devices. However, when I change the menu to be "nav-justified" in the HTML code (using Bootstrap's "nav-justified" CSS class), the menu does not work as expected.
When you tap any menu item with dropdowns, it shows a navigation dropdown on the far left side, which runs outside of the parent CSS frame:
I am also using the Sticky Nav solution found here: How to use the new affix plugin in twitter's bootstrap 2.1.0?
Here is my HTML code for the menu:
<nav class="navbar navbar-inverse" role="navigation">
<div id="nav-wrapper">
<div id="nav" class="navbar">
<div class="navbar-inner">
<div class="container">
<div class="span12">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div> <!-- navbar-header -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav nav-justified">
<li>About</li>
<li>Services</li>
<li>Contact</li>
<li class="dropdown">
Portfolio <b class="caret"></b>
<ul class="dropdown-menu">
<li>1 Column Portfolio</li>
<li>2 Column Portfolio</li>
<li>3 Column Portfolio</li>
<li>4 Column Portfolio</li>
<li>Single Portfolio Item</li>
</ul>
</li>
<li class="dropdown">
Blog <b class="caret"></b>
<ul class="dropdown-menu">
<li>Blog Home 1</li>
<li>Blog Home 2</li>
<li>Blog Post</li>
</ul>
</li>
<li class="dropdown">
Pages <b class="caret"></b>
<ul class="dropdown-menu">
<li>Full Width Page</li>
<li>Sidebar Page</li>
<li>FAQ</li>
<li>404</li>
<li>Pricing Table</li>
</ul>
</li>
</ul>
</div> <!-- collapse -->
</div> <!-- span12 -->
</div> <!-- container -->
</div> <!-- navbar-inner -->
</div> <!-- navbar -->
</div> <!-- nav-wrapper -->
</nav>
And here is the script I have at the bottom of my HTML:
<script>
$(function() {
$('#nav-wrapper').height($("#nav").height());
$('#nav').affix({
offset: { top: $('#nav').offset().top }
});
});
</script>
Here, also, is the obligatory JSFiddle to examine (JS and CSS code linked in the JSFiddle panel on the left): http://jsfiddle.net/L94Mj/
I'm sure I'm somehow dancing around the answer, but this thing has had me stumped for two days now, and I need a fresh brain to look at things. I'm happy to provide whatever extra code is needed to help find the answer.

Change Bootstrap 2.0.4 responsive navbar width

I'm creating a Site using Twitter Bootstrap 2.0.4 + bootstraps responsive.css. What I don't know is: Is it possible to have a logo appearing at the top left of the site and the navbar appearing on the right of the logo (but fixed at top)? While changing Sizes, the Logo should then appear on top of the navbar.
Would be really nice to get an answer for I haven't found anything helpful yet.
Greetings,
Dominik
edit: Here's a picture describing what I want to achieve: http://i.imgur.com/HX3ZM.png
Logo on the left, then navbar.
Okay, I got it. I used the fixed navbar, which didn't work as expected. You have to use a static navbar. Then you could just use the row / scaffolding system from bootstrap.
Example code for a logo left from the navbar:
<div class="row-fluid">
<div class="span3">
<p><img src="/sites/img/your_logo.png" alt="Logo" class="responsive-logo"></p>
</div>
<div class="span9">
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="btn-group pull-right">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<i class="icon-user"></i> Username
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Profile</li>
<li class="divider"></li>
<li>Sign Out</li>
</ul>
</div>
<div class="nav-collapse">
<ul class="nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
</ul>
</div>
</div>
</div>
</div><!-- end navbar -->
</div><!-- end span8 -->
</div><!-- end row -->
To make my Logo responsive, I added the following css rules:
.responsive-logo {
max-width: 100%;
height: auto;
border: 0;
padding-top: 10px;
}
Yes, sure—you will need to re-structure your document to place (for example) a div with the span4 class above the navbar.
Below that, have the navbar code and remove the branding elements (which usually house your logo). My assumption leads me to believe you want something like this:
If you can be a bit more specific about what you want, and/or provide the relevant parts (HTML) of your site, I can likely give some more direction.

Resources