A
A
AlexStartsev2016-04-19 19:53:46
css
AlexStartsev, 2016-04-19 19:53:46

How to make a logo in Bootstrap be responsive?

I am building a website with responsive design. I am using Bootstrap. There is the following code. The CSS is standard for Bootstrap 3.

<nav class="navbar navbar-default navbar-static-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">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#"><img src="img/logo.png" class="img-responsive" alt="Blockchain"></a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <form class="navbar-form navbar-left" role="search">
                    <div class="form-group">
                        <input type="text" class="form-control" placeholder="Search"></i>
                    </div>
                </form>
</div>
</div>

When the screen size is reduced to 332 pixels, the logo jumps to the second row. And I want it to decrease in size (shrink).
Added img-responsive class. But the logo still jumps to the next row. I understand that you need to enclose the logo in the parent element. And what classes and properties to set this div (parent element)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Gleb Kemarsky, 2016-04-19
@alexStartsev

Try adding

@media (max-width: 480px) {
  .navbar-brand {
    float: none;
    display: block;
    overflow: hidden;
  }
}

M
msena, 2016-04-19
@msena

.img-responsive what do you have here? Write.

S
sergey, 2016-04-19
@zorro76

<div><a class="navbar-brand" href="#"><img src="img/logo.png" class="img-responsive" alt="Blockchain"></a></div>

I'm confused, where did you get this? in bootstrap it is written
<a class="navbar-brand" href="#"><img src="img/logo.png" class="img-responsive" alt="Blockchain"></a>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question