"(PHP)WordPress produces a dynamic menu that adapts to different screen sizes

I recently created a menu on my WordPress site [ and I'm facing an issue with making it display vertically in a responsive way.

The code in header.php is as follows:

 <!-- header -->
    <header>
        <div class="overNavPanel">
        <div class="container">
            <div class="col-md-12">
                <div class="row overNavPanel">
                    <div class="col-md-2 col-sm-6" id="logo">
                        <img class="img-reponsive" src="/wp-content/uploads/2015/12/logo.png" alt="logo.png">
                    </div>
                    <div class="col-md-4 col-md-offset-6 col-sm-6" id="top-right-contact">                      
                                    <image class="img-reponsive" src="/wp-content/uploads/2015/12/contact.png" alt="call-icon.png">


                    </div> <!--col-md-4 col-md-offset-7-->      
                </div><!--row-->
            </div>              
        </div>  <!--container-->
        </div><!--overNavPanel-->
        <nav id="myNavbar" class="navbar navbar-default" role="navigation">
            <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle" 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>           
                    </div>
                 <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="navDiv">
            <div class="container">
                <div class="col-md-12">
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                        <ul class="nav navbar-nav">
                        <ul id="nav" class="nav nav-pills nav-justified">
                          <li><?php wp_nav_menu(array('container_class'=>'nav','container'=>'container'));?></li>

                   </div>
                 </div>  
            </div>
        </div>
    </header>
    <!-- /header -->

Answer №1

Here are a few key points to consider:

  1. Be mindful of loading Bootstrap JavaScript only once to avoid issues with collapsing functionality.
  2. The provided HTML structure needs adjustment to align better with Bootstrap examples. You can refer to this fiddle for guidance: https://jsfiddle.net/masa671/bjv1ovbw/
  3. If you're using PHP-generated content, ensure that it generates the correct structure compatible with Bootstrap. This tutorial on integrating Bootstrap navbar into WordPress may be helpful: This one. Do you happen to know which Bootstrap theme you're currently using?

Answer №2

If you're looking to design a responsive menu for your website, you should consider utilizing this helpful plugin: responsive-menu

Alternatively, you can take a look at the options available on this website: navnav.co

There are numerous pre-made responsive navigation menus to choose from, so find one that fits your style and implement its corresponding JavaScript & CSS code.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is the accuracy of Chrome's inspect device not up to par?

I'm currently testing how the page appears on a 1366x768 laptop. When inspected in the device, it looks perfect: https://i.sstatic.net/OECnx.png However, on the actual laptop screen, it's completely off: https://i.sstatic.net/chaeY.png It&ap ...

How can I center an image in HTML while maintaining a slight margin at the bottom

I am facing a minor issue with the bottom margin of an image. I can't figure out why there is a small gap between the image and the menu below. Can someone provide an explanation? My goal is to have the menu align perfectly with the image, but for so ...

Displaying a picture solely in a designated region

I created a basic menu using an unordered list: <ul class="courses"> <a href="#"> <li class="spinny"> <h3>Course Title</h3> <img class="rotateme" src="images/logo_transparent.png"/> </li& ...

Is there a way to customize the CSS of a Bootstrap 4 data table

I recently incorporated a library from Bootstrap Datatables into my project. However, I'm having trouble modifying the CSS for the search bar and 'Excel' button. Is there a way for me to customize it with my own CSS? https://i.sstatic.net/x ...

The text does not automatically move to the next line

How can I make the content in this form section wrap to the next line in a list-item and overlap the width of the div content? The second line, particularly where it mentions Security Question two https://i.sstatic.net/5CVi2.png This is my HTML & CS ...

How to customize the checkbox color in Material UI?

I've been attempting to adjust the color of checkboxes and radio buttons. After conducting some research, I stumbled upon this helpful link: Material UI change Input's active color Unfortunately, I keep encountering the following error: (0 , _ ...

HTML - various incorrect horizontal alignments

I'm having trouble getting the site logo, site name, and site header to align horizontally on my website. They keep ending up in different places.https://i.stack.imgur.com/5yL5f.jpg I'd like it to look similar to this: https://i.stack.imgur.com/ ...

Safari CSS issue: Relative parent and child with pseudo selector not producing consistent output across different browsers

I'm not seeking a specific fix for the code, but rather an explanation as to why it behaves this way. In Safari, children elements with a relative parent appear in a different position compared to other browsers. Changing the child to absolute positi ...

Seeking help with a problem regarding the Tooltip Effect not displaying over a button

I'm currently struggling with implementing a tooltip for the "Back-end" button on my webpage. Despite my efforts, the tooltip effect fails to display over the button, and I'm at a loss as to why. Below is the code snippet I am working with: < ...

Floating CSS3 animations within HTML elements

I'm struggling to understand why the animated arrow on my website refuses to go behind the other elements. The animation code I've used for the arrow in CSS3 is as follows: -webkit-animation-fill-mode:both; -moz-animation-fill-mode:both; -ms-an ...

Gap in footer spacing on Internet Explorer is significantly large

The layout of the page is split into two main sections: A large header that takes up 100% of the browser height The main content area and footer When viewing the page in a browser, only one of these sections will be visible. The following code works wel ...

"Unlock Seamless User Experiences with the Wordpress Screets Plugin and Ajax Login

Currently, I have implemented the use of Screets Wordpress Sessions Plugin along with a customized login form. I chose to avoid using the WP_users database and Wordpress's Admin for Users due to personal reasons. While my login setup functions correc ...

Unable to activate check box button by clicking on it

Hi there! I am having trouble with a checkbox button on my website. The button appears fine, but for some reason it's not working properly (it doesn't get unchecked when clicked). Can anyone help me fix this issue? I'm still learning HTML an ...

placing a dropdown menu below the search bar

Let's say I have a container with an input search field. My goal is to position a select dropdown right below the search input, ensuring that the dropdown has the same width as the search input (similar to autocomplete functionality). Here's what ...

What is the best method for preserving the state of a custom checkbox field in the WooCommerce checkout process

I am facing an issue with the update_post_meta function. I am receiving a user-submitted value via $_POST and trying to save it to post meta. Everything seems to be working correctly, except when the value is '0', the post meta does not get upda ...

Unique approaches: Custom layouts compared to a single adaptive layout for managing various device sizes and orientations

When designing layouts for desktop, tablet, and smartphone in both portrait and landscape orientations within a Single Page Application, is it more effective to separate the layouts as different resources and load them dynamically based on device detection ...

Arrangement of words within a silhouette

I am looking to insert text into a specific shape. The parameters I have include the font, text width, text height, and margin of the text. The text is positioned within a shape with coordinates x and y. Here is an example image: https://i.sstatic.net/Mpq ...

The combination of using p:inputText within p:layoutUnit does not function properly when placed inside p

Recently, I encountered a problem with a modal dialog that contains some input components. The issue arose when I implemented a p:layout within the dialog. Initially, the p:inputText component within a p:layoutUnit functioned properly and gained focus. Ho ...

The MIME type 'text/html' is incompatible with stylesheet MIME type and is not supported

I have exhausted all possible solutions for the issue, from specifying the type for <link rel="stylesheet" href="./style.css" /> to using app.use(express.static('public')), but unfortunately, none of them seem to resolve the problem. index ...

What is the best way to apply styles based on specific screen widths while still having default styles for other screen sizes?

Here is the code snippet I am working with: <TableCell sx={{ borderBottom: { xs: 0, lg: 1 } }}> <Typography variant="body2">{account.name} ({account.currency})</Typography> </TableCell> I am facing an issue where the ...