Dropdown with navbar bootstrap images

Asked

Viewed 1,783 times

0

I’m having a problem disposing a dropdown of images in bootstrap, dropdown this that is inside a navbar

html code:

        <nav class="navbar navbar-default navbar-fixed-top" role="navigation"><!--------- START Navbar --------->
        <div class="container">
            <div class="navbar-header"><!-- START Brand and toggle get grouped for better mobile display -->
                <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
                    <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="#">Meu Site</a>
            </div><!-- END Brand and toggle get grouped for better mobile display -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"><!-- START Collect the nav links, forms, and other content for toggling -->
                <ul class="nav navbar-nav navbar-right">            
                    <li class="dropdown">
                        <a href="#" style="padding-top:0;padding-bottom:0" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                            <img src="../../../images/icon/share-icon.png" 
                            alt="share"/>
                        </a>
                        <ul class="dropdown-menu" role="menu" style="min-width:80px;">
                            <li style="width:50px;">                                    
                                <a href="#"><img src="../../../images/icon/twitter-icon.png" 
                                alt="twitter"/></a>
                            </li>
                            <li style="width:50px;">                                    
                                <a href="#"><img src="../../../images/icon/facebook-icon.png" 
                                alt="facebook"/></a>
                            </li>
                            <li style="width:50px;">                                    
                                <a href="#"><img src="../../../images/icon/tumblr-icon.png" 
                                alt="tumblr"/></a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div><!-- END Collect the nav links, forms, and other content for toggling -->
        </div>
    </nav><!--------- END Navbar --------->

the result: inserir a descrição da imagem aqui

I added Paddings to the images (50px) so that it has the exact size of the navbar (50px) but without success (it is a gray frame around), and the size of the space of the icons also does not get 50px (image size)

2 answers

3


By default . dropdown-menu has a min-width of 160px. You will need to change the style slightly by overwriting the Bootstrap style.

I simulated an examination here.

I hope it helps.

  • Ilá ,@fricks modified his answer to act only on the icon dropdown (I will have another one in the future), I added the css directly in html but I will put it in a separate file later, I edited the question

  • images are not centered

  • Do you want to leave the ul dropdown with 80px? And the images with 50px and center them?

  • Yes I want to center the images

  • Just add text-align:center na li

  • It didn’t work just testing, I also tested class=text-center

  • Look at the example http://www.bootply.com/8KXADmi6JX, it’s working.

Show 2 more comments

0

Browser other questions tagged

You are not signed in. Login or sign up in order to post.