When the collapsible navbar is activated, the logo in the navbar-brand section shifts downwards. I prefer for it to remain fixed

As a newcomer to Bootstrap, I'm venturing into website creation for the first time. Any suggestions on how I can enhance the code would be greatly appreciated!

Query: When collapsing the navbar, I noticed that my navbar-brand logo shifts to the bottom. How can I ensure that the logo remains at the top left corner when the screen size is reduced? Please refer to the linked images for visualization of the issue.

I want the logo to overlap the navbar, which I have successfully achieved as depicted in the "not collapsed" attached image.

collapsed

not collapsed

logo

.navbar {
    max-height: 80px;
}

.navbar-brand {
    padding-top: 90px;
}

.navbar-toggler {
    position: absolute;
}
        <!DOCTYPE html>
        <html lang="en">
        <head>
            <title>Paradise Hotel</title>
            <!-- Required meta tags -->
            <meta charset="utf-8" />
            <meta
            name="viewport"
            content="width=device-width, initial-scale=1, shrink-to-fit=no"
            />
            <!-- Bootstrap CSS -->
            <link
            rel="stylesheet"
            href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
            integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
            crossorigin="anonymous"
            />
            <script
            src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
            integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
            crossorigin="anonymous"
            ></script>
            <script
            src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
            integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
            crossorigin="anonymous"
            ></script>
            <script
            src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
            integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
                crossorigin="anonymous"
            ></script>
              <link rel="stylesheet" type="text/css" href="main.css"/>  
        </head>
        <body>

        <nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark">
            <div class="container-fluid">

                <!-- Logo -->
                <div class="navbar-header">
                <a class="navbar-brand" href="#">
                <img class="img-fluid" src="https://i.sstatic.net/i60Be.jpg" alt="Brand" width="180" height="180" >
            </a>  

            <button
                class="navbar-toggler"
                type="button"
                data-toggle="collapse"  
                data-target="#navbar-menu"
            >
                <span class="navbar-toggler-icon"></span>
            </button>
            </div>  

            <!-- menu items -->
            <div class="collapse navbar-collapse">
                <ul class="nav navbar-nav navbar-right" >
                <li class="nav-item">
                    <a href="#" class="nav-link">Rooms</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">Spa</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">Casino</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">Dining</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">Entertainment</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">Luxury Packages</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">Weddings</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">Contact Us</a>
                </li>
                <li class="nav-item">
                    <a href="#" class="nav-link">FAQ</a>
                </li>
                </ul>
            </div>
            </nav>

            </div>

        </body>
        </html>

Answer №1

The problem lies in attempting to insert an oversized image into your navigation bar, followed by unnecessary adjustments of height and padding. It would be best to resize the image to better suit the navbar.

Simply adjust

width="80" height="80"
and the issue should be resolved.

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

Take out the username field from the registration form in Woocommerce

Is there a way to eliminate the username section from the registration form on woocommerce? I attempted to remove certain lines from the woocommerce/myaccount/login-form.php <?php if ('no' === get_option( 'woocommerce_registration_gene ...

Adding flair to the encompassing container

Below is the HTML code that I am working with: <div class="um-field field-date"> <p class="form-row " id="date_field"> <label class="date"> <input data-label="Date" data-value="" type="date" class="input-date um-frontend-f ...

Spotting the Visible Element; Detecting the Element in

Currently, my webpage has a fixed header and I am facing the challenge of dynamically changing the styling of the li elements within the navigation based on the user's scrolling position. To achieve this, I believe the most effective approach would b ...

CSS - Ignoring Padding Causes Unexpected White Space to Appear

I am encountering a simple error, and the following address will direct you to where the issue can be seen. Why is certain parts of the header appearing white instead of the light shade of green it is set to be? It should be positioned right at the top un ...

The jQuery attr() method is universally compatible across platforms and stands independent

I have a jQuery statement that is currently working for me, but I am unsure if it is cross-platform independent. Can anyone confirm? $("input[name='confirmed']").attr("checked",false); It is functioning correctly on the latest version of Firefo ...

Tips for displaying a Bootstrap 4 table on smaller screens

I have a Bootstrap 4 table filled with JSON data. The table renders perfectly on the UI, but users on smaller devices must scroll to view all the data. Despite there not being much data in the HTML table, users still need to scroll on small devices. I wa ...

What causes the vuetify tag not to render as HTML in the browser?

I ran into a styling issue while using Vuetify in my Nuxt 2 project. Upon inspecting the element in dev tools, I noticed that some Vuetify tags were not being converted to HTML as expected (they were displayed as div class="tag_name"). These unco ...

Customizing #app CSS with Vuetify for development and production environments

After developing my app using vuetify and vue cli, everything was running smoothly in the development environment. However, upon running npm run build, a new default #app CSS was generated and it ended up overriding my custom CSS in the final bundled file. ...

Tips for modifying HTML elements and navigating to a different webpage

As I delve into the world of front-end web development, I decided to challenge myself with a little exercise by creating a basic HTML form. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta ...

Occupying the entire width of a screen

Struggling to tidy up a website I'm working on for a client. I've spent countless hours trying to solve this issue! With my limited knowledge, I could really use some help with the code. The main challenge is making the top section of the site (o ...

Having trouble getting jQuery JavaScript to work on Wordpress and feeling lost about how to implement no-conflict mode syntax

Trying to implement the code from this Codepen http://codepen.io/eternalminerals/pen/qdGvMo on my WordPress website at I understand that since WordPress is in no-conflict mode, I need to change $ to jQuery. I have made this adjustment and ensured that the ...

Issue with Navigation Bar when reducing screen width

I'm currently working on creating a navbar that includes an image logo, title, navigation links, and social links. To achieve this, I've divided the navbar into 4 separate divs. However, I've noticed that when I decrease the screen width usi ...

When the content within a dialog element exceeds the boundaries of the dialog, it will not be displayed

Issue Struggling with creating a dialog element that includes an x button for closing the <dialog> in the upper-right corner. My initial idea was to utilize absolute positioning and transforms to achieve this functionality, but encountered a setback ...

Generate dynamic maps that are exportable to HTML format

I've utilized Leaflet to produce engaging interactive maps in R. However, I'm encountering an issue when trying to export the maps - the background map appears grey after exporting. library(leaflet) library(htmlwidgets) m <- leaflet(data.fra ...

CSS - Revealing an element on the backface post flip animation

I encountered an issue while working on a CSS flip card project. Despite using backface-visibility: hidden;, one element remains visible from the other side. In the simplified snippet provided, if you click on more in the bottom right corner, the card fli ...

Is there a way to use Javascript to launch a new page on my website?

I'll do my best to provide a clear explanation of what I need. Take a look at this: My website is filled with a plethora of news articles, all retrieved from the MySQL database using select * from table_name. Displaying so much news on one page can ...

How to properly adjust image size in a flex-direction column layout - tips and solutions

My mission is to place an <img> with text blocks above and below it inside a container of specified height. The exact heights of the text blocks and image are unknown. After extensive searching, my colleague provided a useful solution by using the ...

Utilizing hover effects and timeouts to conditionally show React components

I encountered a challenging React layout dilemma. It's not a complex issue, but rather difficult to articulate, so I made an effort to be as clear as possible. The data I have maps individual components in the following way: map => <TableRow na ...

The issue with the `.load` function in jQuery not functioning properly

I'm currently tackling an issue with a project where I am encountering difficulties with the .load function not working in Google Chrome. Below is the JavaScript code: function link1() { $('#loadarea').html('loading.....' ...

Images on a webpage can cause the height of a div element to remain

I've encountered a problem with displaying 5 images horizontally on the screen. For some reason, I'm unable to set the height of the Div "block-before-description". In FireBug, the height appears as 0 while the 20px margin is visible. Despite try ...