Tips on creating a responsive shopping cart and favorites button

My Bootstrap navbar includes a shopping cart and favorites button. However, when the screen size hits 992px, the navbar switches to a hamburger collapse menu. This causes the cart and favorites buttons to spread out awkwardly. I need assistance in displaying these buttons from the dropdown menu in a user-friendly way on tablet and mobile devices. Below is my code for the nav along with a link to the site.


    <nav class="navbar navbar-expand-lg navbar-light bg-light">
      <div class="container-fluid">
        <a class="navbar-brand" href="index.html" ></a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarText">
          <ul class="navbar-nav me-auto mb-2 mb-lg-0">
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle active" aria-current="page" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                Category
              </a>
              <ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                <li><a class="dropdown-item" href="#">Mens</a></li>
                <li><a class="dropdown-item" href="#">Jackets</a></li>
                <li><a class="dropdown-item" href="#">Outer Wear</a></li>
              </ul>
            </li>
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" aria-current="page" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                Collection
              </a>
              <ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                <li><a class="dropdown-item" href="#">Winter</a></li>
                <li><a class="dropdown-item" href="#">Spring</a></li>
                <li><a class="dropdown-item" href="#">Summer</a></li>
                <li><a class="dropdown-item" href="#">Fall</a></li>
              </ul>
            </li>
            </li>
            
          </ul>
          <span class="navbar">
            
            <i> <a type="button" class="btn fab fa-gratipay"href="favorites.html" target="_self"> <span class="favoritesCount"></span> </a></i>
               
            <i> <a type="button" class="btn fas fa-shopping-cart Cart" href="cart.html" target="_self"  ><span class="navbarCart" data-totalitems="0"></span></a></i>
          
          </span>
        </div>
      </div>
    </nav>
  </section>

Here is the CSS

/* nav container */
.container-fluid{
  border-bottom: black solid 3px ;
  width: 100%;
  
  height: 50px;
  
}
.container-fluid a{
  margin-left: 3%;
  
}
/* .navbar-brand
{
    position: relative;
    background: url(../images/logo.png);
    width: 170px;
    left: 15px;
    max-height: 70px; 
} */
.navbar-brand
{
    position: relative;
    background: url(../images/fakeLogo.png);
    width: 100px;
    height: 40px;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
}


.navbar span{
  padding: 0 8px;
  margin-right: 3%;
}
.Cart{
  width: 100px;
  font-size: 40px;
  color: #000;
  padding: 0;
  position: relative;
}

If you require additional code or information, please feel free to let me know.

Answer №1

Just making sure I understand your question... Are you looking to prevent the spread of your favorite and cart icons across the page?

To achieve this, you should delete the justify-content: space-between; property from the span.navbar element.

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

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

Default cursor: ASP.NET input elements

On my webpage, there are around twenty input fields that can be dynamically changed. Once the form is submitted and finalized, it becomes view-only, meaning it can no longer be edited. To achieve this, I created a string called "disabled" that is set to d ...

Determining the visible dimensions of an iframe

Is there a way to determine the visual size inside an iframe using JavaScript or jQuery? In this scenario, only a portion of the iframe is displayed. The iframe itself has dimensions of 300x300, but it is being limited by a div to 300x100. <div style= ...

Organize every rectangle and text element in D3 into distinct groups

Currently, I am working on creating a bar graph using d3.js. The goal is to display text on top of each bar when the user hovers over it. To achieve this, the <text> and <rect> elements need to be grouped inside a <g> element. For Exampl ...

Placing a div within a 960 grid system can sometimes result in unexpected spacing

Testing on various browsers: Chrome, IE, Firefox. I'm facing an issue where the BusinessNav ID keeps getting pushed over 3 columns. Desired page layout can be found here I could definitely hack this code to adjust the positioning. However, with so m ...

text within the table is overlapping when being created dynamically in the <table> using javascript and jquery.quickflip.js

Hello everyone, I am currently working on dynamically generating a table using tabs created with jquery.quickflip.js. However, I have run into an issue where the text from one tab may overwrite values in another tab when switching between them. Below is ...

Step-by-step guide on importing .obj and .mtl files into a Vue component with Vue CLI 3

Being new to VueJs and Three, my code is mostly just copied and pasted. I am trying to figure out how to load a 3D file (.obj) and its corresponding material file (.mtl) into a Vue component. I have already installed Three.js and imported the necessary loa ...

Set the input of a component in Angular to determine its width

I am working on a basic angular component. Here is the code snippet: <div class="k-v-c" fxFlex fxLayout = "row" > <div class="k-c" fxFlex = "widthOfTable" > {{ key | translate }} </div> < div class="separator" > ...

What is the best way to expand a footer's height to fill the remaining space on the screen?

Any idea how to achieve this look: Creating a footer that stretches to fill the remaining height of the screen at the bottom of the page. Can CSS make this happen? ...

Utilize JavaScript to extract an image from an external URL by specifying its attributes (id, class)

Is it possible to fetch an image from an external website by using its CSS id or class in conjunction with JavaScript/jQuery's get methods? If so, could someone provide guidance on how to achieve this task? ...

Place 4 divs within 2 divs, with one aligned to the left and the other to the right

I'm currently working on a small project using Angular 2 for an experiment, where I need to place 4 divs, each containing an image, within 2 divs. However, all the divs (with images) are stacked vertically instead of being placed next to each other, ...

I need to mass upload a collection of resumes stored in a zip file, then extract and display the content of each resume using a combination of HTML

I recently used a service to extract and retrieve the contents of a zip file. I am trying to read the content of the files and integrate them into the scope of my Angular project. Any suggestions would be greatly appreciated. Below is an outline of my func ...

Tips for guaranteeing that HTML elements maintain distinct ids when duplicated within a design

Looking for a solution to ensure unique IDs in a piece of HTML code within a DTL for loop. {% for job in work_experience %} <div class="work-exp-item"> <h4 id="exp-title" class="body-text">{{ job.title }}</h4> <h5 id="exp-comp ...

Executing a JavaScript function within a PHP echo statement

I am completely new to working with AJAX and PHP echo variables or arrays. However, I have managed to successfully display images on my website by passing variables from AJAX to PHP and back. The only problem I am encountering is when I try to call a Javas ...

Numerous volume sliders catering to individual audio players

I'm currently working on implementing volume sliders for multiple audio players, similar to what you can find on . With the help of Deepak, I've managed to create code that allows me to control play/pause and adjust the volume of various audio pl ...

Troubleshooting Issue with Ionic's UI Router

Recently, I created a basic Ionic app to gain a better understanding of UI router functionality. To my surprise, when I ran the app, nothing appeared on the screen. Additionally, the developer tools in Google Chrome did not show any errors or information. ...

Unable to access a hyperlink, the URL simply disregards any parameters

When I click an a tag in React, it doesn't take me to the specified href. Instead, it removes all parameters in the URL after the "?". For example, if I'm on http://localhost:6006/iframe.html?selectedKind=Survey&selectedStory=...etc, clicking ...

Retrieve the username from one table and insert it into a different table

Learning PHP has been quite a challenge for me today. I've been trying to pull information from a user's database into a file and then use it in a form to insert into another table. My issue is with getting the user's ID and username. I suc ...

Add extra space to the dimensions of the div by incorporating padding

Showing my issue with an accompanying image: I am looking for a solution to include padding in the width: 50%; calculation. Currently, the first div's width is actually 50% + 2em because the padding was not factored in initially. Is there a way to i ...

What is the method for changing the color of text within a button when hovering using CSS?

In my OceanWP WordPress theme, I customized the top-bar menu by adding a button labeled "Post a Job" using CSS. Screenshot Link I have two top-bar menus - one for logged-in users and another for logged-out users. The "post a job" button has a 2px purple ...

Eliminate embellishments upon hovering over hyperlinks

Is there a method to prevent my links from becoming underlined or changing color when hovered over? ...