I want to make header contains logo and menu.
I maked row and two columns. I used booеstrap classes. When I resize window to smaller, menu jumps under logo (look at my picture). In this moment when screen width is small and menu jumps under logo I wanna make collapse menu, but I dont know how to write it to code:
My HTML code:
<div class="mycontainer container-fluid">
<div class="container">
<div class="row">
<div class="logo col-md-4">
<a href = "/" class = "logo"><img src="/bendikon/wp-content/themes/bendikon/images/logo.png" alt="banner"></a>
</div>
<div class="header-menu col-md-8">
<?php if ( has_nav_menu( 'primary-menu' ) ) { ?>
<?php wp_nav_menu( array( 'theme_location' => 'primary-menu') ); ?>
<?php } else { ?>
<ul class="sf-menu">
<li><a href="/">Home</a></li>
<li><a href="/?page_id=2">Sample Page</a></li>
<li><a href="/?p=1">Sample post</a></li>
</ul>
<?php } ?>
</div>
</div>
</div>
</div>
The bootstrap wrap is used to cover or wrap the flex items in a flex container.It has main three classes which is . flex-wrap, . flex-nowrap, . flex-wrap-reverse.
The Flexible Box Layout Module in bootstrap is used for designing the flexible and responsive layout structure. It is used in Bootstrap 4. The d-flex class is used to create a simple flexbox container.
The gutters between columns in our predefined grid classes can be removed with .g-0 . This removes the negative margin s from .row and the horizontal padding from all immediate children columns.
col-sm-4 are available for quickly making grid layouts. Columns create gutters (gaps between column content) via padding. That padding is offset in rows for the first and last column via negative margin on .
you can use flex-nowrap
like this:
<div class="row flex-nowrap">
<div class="col"></div>
<div class="col"></div>
</div>
check it here: Bootstrap 4.0 flex-nowrap
try with the class col-xs-8
and col-xs-4
instead of col-md-8
and col-md-4
. Is normal that your columns are displayed as a plain blocks if you don't tell them how behave on xs size.
Also you might want to add the class img-responsive
to your logo img tag to limit the maximum width to 100% of the containing column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With