Responsive Bootstrap navigation bar with a prominent logo

I am currently working on creating a navigation bar with logo following two different layouts. The first layout should be centered vertically and look like this on desktop: Desktop Layout

For mobile devices, the layout should resemble this design: Mobile Layout

To achieve this, I have written the following code snippets:

<div class="row">
        <div class="col-md-3">
            <a href="#" class="pull-left">
                <img src="image/logo.png" height="300px" id="logo" class="img-responsive">
            </a>
        </div>

        <div class="col-md-9">
            <nav class="navbar navbar-default" role="navigation">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle"
                            data-toggle="collapse" data-target="#example-navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    </a>
                </div>
                <div class="collapse navbar-collapse" id="example-navbar-collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a href="#">Search</a></li>
                        <li><a href="#">Archives</a></li>
                        <li><a href="#">Education</a></li>
                        <li><a href="#">About</a></li>
                    </ul>
                </div>
            </nav>
        </div>
    </div>

Although the code is functional, I am facing issues with centering the navbar vertically and positioning the logo correctly on mobile view. Any suggestions on how to achieve these layouts would be greatly appreciated! :)

Answer №1

It seems like the images are not showing up correctly, which is making it difficult to understand your question. Based on my interpretation, it sounds like you're experiencing a problem with space running out on mobile devices, causing the elements to stack. One solution could be to add a resizing attribute to the logo so that it displays properly on mobile screens. It may also be helpful to review and clarify your question for better assistance.

Answer №2

Have you considered using align="center"?

<div align="center" style="max-height:inherit">
 <div class="col-md-9">
        <nav align="center" class="navbar navbar-default" role="navigation">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle"
                        data-toggle="collapse" data-target="#example-navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                </a>
            </div>
            <div class="collapse navbar-collapse" id="example-navbar-collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#">Search</a></li>
                    <li><a href="#">Archives</a></li>
                    <li><a href="#">Education</a></li>
                    <li><a href="#">About</a></li>
                </ul>
            </div>
        </nav>
    </div>

Please give it a try and let me know if it works for you.

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

Inserting information into a SQL database using PHP

Looking for some assistance here. I've double-checked the SQL table names multiple times, but whenever I try to post, I keep getting an error. I'm fairly new to this, so any help would be greatly appreciated. Thanks in advance. require_once(&ap ...

Thymeleaf: Expression parsing error

I am working on a Thymeleaf template that includes pagination functionality. <ul class="results_perpage" > <li th:if="${previous != null}"><a th:href="javascript:movePage(`${previous}`);" class="results_menu" th:text="PREVIOUS">< ...

Click once to change the element, but it will remain changed and will not revert back no matter how many times you

After the first click displaying "X" and then changing to "O" in my tic-tac-toe JavaScript game, subsequent clicks only show "O", failing to switch back to "X". I am currently working on creating a tic-tac-toe game using JavaScript. Upon the first click, ...

PHP script for converting HTML lists to plain text

Looking to convert HTML ordered/unordered lists into plain text for export to a txt file? Here's an example: Original HTML: <ol><li>Item 1</li></li>Item 2</li><li>Item 3</li></ol> Desired format: 1. ...

python scraping: how to extract two nested elements

Hello, I am looking to extract information from the < del> and < ins> tags below. However, I haven't been able to find a solution yet. Does anyone have any ideas on how to scrape this data? This is my Python code: import requests import j ...

Showing content in HTML

I am trying to implement a feature that displays the value from a search bar into Search results for a specific term. Despite my efforts, the code I have written so far doesn't seem to be working. Can someone help me figure out why? <!DOCTYPE h ...

Executing the same function on both mouse click and key press with HTML and JavaScript

I need help figuring out how to call the same JavaScript function whether a user clicks a mouse or presses the enter key. Here is the code I have in my HTML file, but it doesn't seem to be working. Can anyone advise on how to fix this issue? <div ...

VueJS encountered an issue while displaying the image

I am facing an issue with VueJS while trying to populate my index.html with images fetched from the iTunes API. The API returns a URL to an image, but I am struggling to render them on my webpage. The 'item' variable holds the object data. Initi ...

`Something to keep in mind: Chartist in jspm does not import CSS files`

I'm running into some issues trying to import the chartist library with my jspm Aurelia application. I've added all the necessary styles, but the chart is not displaying as expected in terms of colors and lines. Here's the code snippet incl ...

Creating a vertical collapsible navigation menu with Bootstrap 4

I'm currently utilizing Bootstrap 4 and attempting to display a straightforward vertical collapsible menu. <div class="row"> <div class="col-3"> <div id="accordion"> <div> <div id="ta ...

Verify the presence of a specific select option using text in jQuery version 1.7

Looking at the following snippet of HTML: <select id="sel"> <option value="0">Option1</option> <option value="1">Option2</option> <option value="2">Option3</option> <option value="3">Option4</option> & ...

Database query is failing to return any results

Currently, I am developing a URL shortener system which involves storing data in my database such as an id, url, code, and created. However, I encountered an issue where the code does not return the required code despite checking if the entered url exists. ...

Material-UI: Eliminate the missingOppositeContent:before element from TimelineItem

I'm currently using Material-UI to construct a timeline. Here is the code snippet I am working with: <Timeline align="right" className={classes.monthlyContainer}> <TimelineItem > <TimelineSeparator className={class ...

What are some techniques for improving the performance of this Javascript function?

I implemented a procedure to change the style of my top navigation bar based on the user's scroll position on the page: /* Handling changes in the top nav during page scrolling */ window.onscroll = function () { if ($(window).scrollTop() > 150 ...

Creating a navigation bar in React using react-scroll

Is anyone able to assist me with resolving the issue I am facing similar to what was discussed in React bootstrap navbar collapse not working? The problem is that although everything seems to be functioning properly, the navbar does not collapse when cli ...

Having trouble getting the img file to show up in the img tag - the src URL is not updating

<div class="col-lg-3 col-md-4 pl-md-1"> <label class="ORGAd16-preview"> input type='file' name="modelvariant_file" id="imageUpload" accept=".png, .jpg, .jpeg" > <img id="ima ...

Switching between classes using jQuery

I'm working on implementing a play and pause button for a video, and I'm facing an issue with switching the class when the button is pressed. What I want is that when the pause button is clicked, the class changes to something else, and vice vers ...

Exploring the depths of complex structures with Selenium to uncover hidden elements

If we look at this particular piece of HTML code: <tr class="highlight"> <td><center><a href="example.code"> Bar </a></center></td> <td><center> Foo </center></td> &l ...

What are some quality open APIs available for web-based frontend painting tools?

I am in the process of creating an HTML5/JavaScript application inspired by: Although I could simply copy and paste their source code, I am concerned about potential copyright issues. Instead, I am exploring the option of using free APIs that offer simila ...

Tips for incorporating fixed div columns within ngFor?

I need help implementing a design where I have a dynamic array of data that I want to display in 3 bootstrap columns per row like the following: <div class="row"> <div class="col-md-4"> <a>data</a> <a>data</a> ...