Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text next to brand

How do I get the Bootstrap Brand and any accompanying text to be treated together as the brand?

I have tried this:

<nav class="navbar navbar-default">
    <div class="navbar-header">
        <div class="navbar-brand">
            <a href="..." ><img class="img-responsive" src="/brand.png")?>"></a>
            <h3>Ultimate Trade Sizer</h3>
        </div>
    </div>
</nav>

However, I can't get them to be aligned (i.e. side by side). It produces the below effect:

Title and logo should be side-by-side

Please note that I am using Bootstrap 3.

like image 660
iamyojimbo Avatar asked Dec 10 '13 18:12

iamyojimbo


People also ask

How do I add content to my navigation bar?

Use <h4> tag to add the heading for the navigation bar. Use <ul> tag to define unordered (unnumbered) lists. Use <li> tags within the <ul> tag to add list items to the unordered list. Use <a> tag to add a hyperlink to any content on the web page.

How to add text in navbar bootstrap?

To add form elements inside the navbar, add the .navbar-form class to a form element and add an input(s). Note that we have added a .form-group class to the div container holding the input.

What does navbar toggler do?

navbar-toggle and then features two data- elements. The first, data-toggle, is used to tell the JavaScript what to do with the button, and the second, data-target, indicates which element to toggle. Then with a class . icon-bar create what we like to call the hamburger button.


3 Answers

Wrap the image in a span

<nav class="navbar navbar-default">
    <div class="navbar-header">
        <a class="navbar-brand" href="#">
            <span><img src="#"/></span>
            Ultimate Trade Sizer
        </a>
    </div>
</nav>

span defaults to display: inline

like image 160
Pierre de LESPINAY Avatar answered Oct 10 '22 13:10

Pierre de LESPINAY


The correct solution would be to use navbar-text on the h3 and not to use any additional div or span elements:

<nav class="navbar navbar-default">
    <div class="navbar-header">
        <div class="navbar-brand">
            <a href="...">
                <img class="img-responsive" src="/brand.png">">
            </a>
            <h3 class="navbar-text">Ultimate Trade Sizer</h3>
        </div>
    </div>
</nav>

See http://getbootstrap.com/components/#navbar-text for the proper documentation of navbar-text.

like image 20
lanoxx Avatar answered Oct 10 '22 11:10

lanoxx


Not sure if this is correct html but I wrapped the image and text in a new div class and floated that left. Also changed the img to the new class with some padding on the right to space it from the text. Seemed to work for me but I am pretty new to bootstrap so it might not be exactly right. Your code would look like this.

html

<nav class="navbar navbar-default">
    <div class="navbar-header">
        <a class="navbar-brand" href="#">
            <div class="navbar-brand-name">
                <img src="#"/>
                     Ultimate Trade Sizer
            </div>
        </a>
    </div>
</nav>

add the new css class under the .navbar-brand class

.navbar-brand-name > {

  display: inline-block;
  float: left;

}

.navbar-brand-name > img {
  display: inline-block;
  float: left;
  padding: 0 15px 0 0;
}
like image 12
Rob Avatar answered Oct 10 '22 12:10

Rob