Stop bootstrap from pushing image onto new line within the navigation bar

I need the navbar to show the donation bar on the same line as the navigation options. When resizing the image, it drops down as shown below. I have attempted using responsive img tags and divs with column sizes, but they have not been successful.

As an additional question: How can I align the nav items with the buttons? The bread and donation buttons are slightly off, and padding adjustments do not work.

https://i.sstatic.net/ai40U.png

        <!-- Collect all nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse navbar-ex1-collapse">
            <ul class="nav navbar-nav">
                <!-- Hidden li used to remove active class from about link when scrolled up past about section -->
                <li class="hidden">
                    <a class="page-scroll" href="#page-top"></a>
                </li>
                <li>
                    <a class="page-scroll" href="news.html">News</a>
                </li>
                <li>
                    <a class="page-scroll" href="aboutus.html">About us</a>
                </li>
                <li>
                    <a class="page-scroll" href="team.html">Our Team</a>
                </li>

                <li>
                    <a class="page-scroll" href="volunteering.html">Volunteer</a>
                </li>

                <li>
                    <a class="page-scroll" href="contactus.html">Contact</a>
                </li>

                <li>

                <div class="dropdown">
                  <button onclick="location.href='donation.html'" class="dropbtn2" >Donate</button>
                  <div class="dropdown-content">
                    <a class="page-scroll" href="donation.html#section1">SET DONATION</a>
                    <a class="page-scroll" href="donation.html#section2">GIFT A DONATION</a>
                  </div>
                </div> 

                </li>



            </ul>
            <a href="donation.html"><img class="alignright hidden-xs" src="icons/fundraisingbar.png"></a>




        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav>

CSS:

/* Dropdown BOX */

        /* Dropdown Button */
        .dropbtn {
            background-color: #F8F8F8;
            color: 777777;
            padding: 16px;
            font-size: 16px;
            border: none;
            cursor: pointer;
        }

        .dropbtn2 {
            background-color: #F8F8F8;
            color: red;
            padding: 16px;
            font-size: 16px;
            border: none;
            cursor: pointer;
        }


        /* The container <div> - needed to position the dropdown content */
        .dropdown {
            position: relative;
            display: inline-block;
        }

        /* Dropdown Content (Hidden by Default) */
        .dropdown-content {
            display: none;
            position: absolute;
            background-color: #f9f9f9;
            min-width: 160px;
            box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
            z-index: 1;
        }

        /* Links inside the dropdown */
        .dropdown-content a {
            color: black;
            padding: 12px 16px;
            text-decoration: none;
            display: block;
        }

        /* Change color of dropdown links on hover */
        .dropdown-content a:hover {background-color: #f1f1f1}

        /* Show the dropdown menu on hover */
        .dropdown:hover .dropdown-content {
            display: block;
        }

        /* Change the background color of the dropdown button when the dropdown content is shown */
        .dropdown:hover .dropbtn {
            background-color: #3e8e41;
        }

Answer №1

How about relocating the button outside the div and placing it within its own <li>:

<!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse navbar-ex1-collapse">
            <ul class="nav navbar-nav">
                <!-- Hidden li included to remove active class from about link when scrolled up past about section -->
                <li class="hidden">
                    <a class="page-scroll" href="#page-top"></a>
                </li>
                <li>
                    <a class="page-scroll" href="news.html">News</a>
                </li>
                <li>
                    <a class="page-scroll" href="aboutus.html">About us</a>
                </li>
                <li>
                    <a class="page-scroll" href="team.html">Our Team</a>
                </li>

                <li>
                    <a class="page-scroll" href="volunteering.html">Volunteer</a>
                </li>

                <li>
                    <a class="page-scroll" href="contactus.html">Contact</a>
                </li>
<li>
  <button onclick="location.href='donation.html'" class="dropbtn2" >Donate</button>
</li>
                <li>

                <div class="dropdown">

                  <div class="dropdown-content">
                    <a class="page-scroll" href="donation.html#section1">SET DONATION</a>
                    <a class="page-scroll" href="donation.html#section2">GIFT A DONATION</a>
                  </div>
                </div> 

                </li>



            </ul>
            <a href="donation.html"><img class="alignright hidden-xs" src="icons/fundraisingbar.png"></a>




        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav>

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

What is the best way to make HTML adjust to SVG scaling?

After applying a scale transform to an SVG, I noticed that the surrounding HTML does not adjust its size accordingly. Here is the SVG in question: <div> <svg height="300" width="300" viewbox="0 0 300 300" transform="scale(1.55)" xmlns= ...

Verify the checkboxes in one row

How can I create a table row that will automatically generate data from SQL and bind it using backend code? Is there a way to check if the user has clicked on it using JavaScript? The row is created as shown below: <tr> <td align="right" cl ...

Tips for aligning flex items based on the previous item in a flex container

Place 'text1' beneath the number 1 (so that the 't' character is under the 1), and 'text2' beneath the number 5 (with the '2' character under the number 5) This should be done dynamically to adjust to a varying numb ...

Dynamic content is loaded on the page using AJAX before refreshing to retrieve new

I am using the FullPage.js plugin and attempting to enable navigation between pages using AJAX. While using .load();, I am able to retrieve the desired page. However, it seems that I need to reload fullpage.js since the loaded page is not active and the s ...

What is the method for accessing two distinct values through a single checkbox?

Using a combination of HTML, PHP, and jQuery for my website development, I have implemented a checkbox within a form: <input type="checkbox" name="check_status" id="check_status" value="1"> Status I am looking to use the same checkbox for two diffe ...

Mastering the art of passing props between components in React

I am striving to leverage data from a JSON file to pass specific information using props in React, with the aim of loading multiple images (cards). This project involves three key components: App, MainCard, and a JSON file named Data. I am facing challen ...

The alignment of 5 boxes is off, failing to position them in the center of the page

Just dipping my toes into the world of programming. I managed to line up 5 boxes horizontally, but now I want to center them. The challenge is also making sure the boxes remain responsive. I've been scouring for ways to center a div, and all I come up ...

PHP code not inserting the expected value into MySQL database

I'm having an issue with saving images to my server using PHP and MySQL. When I try to save the image, only the folder location appears in the database table, not the actual image name. Any suggestions on how to fix this? Here is the code I am curre ...

Is it possible for me to insert a hyperlink that will show a PDF in a web browser without triggering a download?

I am looking for a way to allow visitors to my website to easily access and view a PDF directly in their browser by clicking on a specific URL or button. I want the PDF to be displayed within the browser itself, rather than prompting a download. Any guidan ...

Sending data from Ajax to PHP and saving it in a database

Hello, I'm facing an issue. I am trying to pass a JavaScript variable to my PHP script and store it in a MySQL database but for some reason, it's not working. Below is the code I am using: JavaScript: <script type="text/javascript"> ...

Which data structure is suitable for storing a JSON object?

Currently, I have a form set up in the following way: using (Ajax.BeginRouteForm( ... new AjaxOptions { HttpMethod = "POST", OnFailure = "OnFailure", OnSuccess ...

When no items are available, the drag and drop functionality does not function

When I am performing drag and drop between two containers, everything functions correctly when there is at least one element present in the container. However, if I remove all elements from either container and try to drag them back, the operation fails. ...

Enhancing Efficiency and Optimization with jQuery

Recently delving into the world of jQuery, I have been on the lookout for ways to enhance the speed and performance of my code. If anyone has any tips or valuable resources that could aid me in this endeavor, I would greatly appreciate it. Thank you, Bev ...

Best practices for refreshing the HTML5 offline application cache

My website utilizes offline caching, and I have set up the following event handler to manage updates: applicationCache.addEventListener('updateready', function () { if (window.applicationCache.status == window.applicationCach ...

Which is better to use: sql==true or sql===true?

Hey there, could you please take a look at this and thanks in advance! I'm currently working on developing a system for upgrading buildings in my game. I have set up a universal upgrade div that applies to all buildings. When the player clicks on a bu ...

Issues with AJAX Load functionality

As a beginner in jQuery, I am experimenting with an AJAX load function. However, I am encountering difficulties in making it work. Despite trying different approaches and file formats (.php, etc.), I ended up using the first method I attempted. My goal is ...

Deleting tasks from the to-do list using Node.js and Express with EJS

Looking to implement functionality where each list item can be removed from a Node.js array by clicking on an HTML button using EJS and Express: I am considering placing an HTML button next to each list element so that the selected element can be removed ...

An error occurred when executing Selenium through Python due to an invalid selector issue

While attempting to save a document, I encountered an issue. Using Firefox and the Firefox IDE, the following target worked perfectly: css=div.ui-dialog-buttonset button:contains('Yes, ') However, when trying to implement it in Python with the ...

Scrollable floating div concept

I've been on the hunt for a floating div/menu that can do more than just float as shown in this example When the height of the floating div/menu exceeds that of the viewport, I need it to allow scrolling with the main scrollbar so I can view all part ...

Discover the method for retrieving the value of a toggle-style checkbox

I am currently working with a toggle switch checkbox and I need to extract its value using JavaScript or jQuery when the state changes. Based on this value, I aim to highlight the text of the label associated with the toggle switch, whether it's opti ...