Konrad Albrecht
Konrad Albrecht

Reputation: 1889

Bootstrap centering menu element

I have troubles centering the logo and menu in the md and sm view.

I want to animate margin of brandlogo and li in menu so margin auto and position absolute is nogo

TransformX and col-offset is kinda centering but not pixel perfect and when animatin margin the logo and menu do not stay centered.

<nav class="navbar navbar-default navbar-fixed-top container menufix">


                <div class="row row-eq-height" id="rowmenu">
                    <div class="row row-eq-height-resp">
    <!-- Brand Logo --> 
                        <div class="col-xs-10 col-sm-12 col-md-12 col-lg-12">
                            <a class="navbar-brand" id="brand-logo" href="#">
                                <img alt="BrandLogo" class="brandlogo" src="/wp-content/themes/kdproduction/logo.png">
                            </a>
                        </div>
    <!-- Brand and toggle - mobile display -->
                        <div class="col-xs-2 hidden-lg hidden-md hidden-sm">
                            <button type="button" class="btn-resp-style" data-toggle="collapse" data-target=".navbar-collapse">SVG</button>
                        </div>
                    </div>

<!-- Main Top nav -->
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-8" >
                        <div class="navbar-collapse collapse">
                                <?php wp_nav_menu( array( 
                                    'theme_location' => 'primary',
                                    'container' => false,
                                    'menu_id' => 'kdnavmenulista',
                                    'menu_class' => 'nav navbar-nav navbar-header kdnavmenulista'
                                        )); 
                                ?>
                        </div><!-- /.navbar-collapse -->
                    </div>
                </div>
        </nav><!-- /.container -->

Upvotes: 0

Views: 84

Answers (1)

Varin
Varin

Reputation: 2443

Instead of this:

<a class="navbar-brand" id="brand-logo" href="#">
    <img alt="BrandLogo" class="brandlogo" src="/wp-content/themes/kdproduction/logo.png">
</a>

try and put this:

<div style="width:100%; display:flex; justify-content:center; align-items:center;">
    <a class="navbar-brand" id="brand-logo" href="#">
        <img alt="BrandLogo" class="brandlogo" src="/wp-content/themes/kdproduction/logo.png">
    </a>
</div>

Let me know if it worked.

Upvotes: 1

Related Questions