question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navbar Logo and brand link overlapping if they both get same class

See original GitHub issue
     <a href="#!" class="brand-logo left">LOGO</a>  
        <ul class="left hide-on-med-and-down">

when give same direction class they overlap, better to be on the right or left of logo based on direction

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
iNilocommented, Sep 16, 2016

Screenshot

<nav>
    <div class="nav-wrapper">
        <a href="#!" class="brand-logo">Logo</a>
        <a href="#" data-activates="mobile-demo" class="button-collapse"><i class="material-icons">menu</i></a>
        <ul class="left hide-on-med-and-down">
            <li><a href="sass.html">Sass</a></li>
            <li><a href="badges.html">Components</a></li>
            <li><a href="collapsible.html">Javascript</a></li>
            <li><a href="mobile.html">Mobile</a></li>
        </ul>
        <ul class="side-nav" id="mobile-demo">
            <li><a href="sass.html">Sass</a></li>
            <li><a href="badges.html">Components</a></li>
            <li><a href="collapsible.html">Javascript</a></li>
            <li><a href="mobile.html">Mobile</a></li>
        </ul>
    </div>
</nav>
1reaction
doughballscommented, Jun 25, 2020

This question is a little complex.

It’s important to understand that .brand-logo uses position:absolute - which means it gets taken out of the flow of the page. The ul links do not see it, so that is why they overlap. To them, it is not even there.

The best solution here is not to be adding inline margins - these values could change in future, if the font changes, or the letter spacing, or the site name - and then the spacing will be out.

Removing position:absolute from .nav-logo is one solution, and using floats on on the logo and the ul:

nav .brand-logo {
  position: relative;
}

https://codepen.io/doughballs/pen/gOayyyV

we put the logo back into the flow of the page, and then float both left.

It gets even more complex here. ul; by default is a block level element. If we take the float off, then it sits under the logo, under the nav! If we change to display:inline, it moves back up into the nav, but before the brand logo!

.left is a utility class - a simple helper to float something left or right. It is sometimes better not to use utility classes, and write css that takes complete control of the component. it is not great in this example to have multiple left classes. (We can achieve the same thing with css with fewer classes)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap navbar-brand logo overlapping on collapse
By default, when I added my logo wrapped with the navbar-brand class as in their documentation example, the logo overhangs off the navbar....
Read more >
How to Create, Edit, & Make Your Navbar Awesome in Bootstrap
Learn how to create an awesome navigation bar for your Bootstrap site so you can help visitors browse your site faster and easier....
Read more >
Navbar - React-Bootstrap
A powerful, responsive navigation header, the navbar. Includes support for branding, navigation, and more. Overview#. Here's what you need to know before ...
Read more >
Bootstrap Navbar - examples & tutorial
A basic example of the navbar with the most common elements like link, search form, brand, and dropdown. All of them are explained...
Read more >
Navbar - Bootstrap
Here's what you need to know before getting started with the navbar: ... As a link --> <nav class="navbar navbar-light bg-light"> <a class="navbar-brand" ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found