Clearing the box-shadow effect when collapsing the side bar using a toggle button

I have been struggling with removing the box-shadow from my sidebar when it collapses. I have tried various CSS methods like box-shadow: none;, box-shadow: none !important;, and box-shadow: transparent;. I even attempted changing the color to box-shadow: yellow; but none of them seem to work. How can I successfully remove the shadow when the sidebar collapses? This issue pertains to React components:

    <div>
      <div className="sidebar-container container-flex navbar-expand-sm navbar-light">
        <div className="navbar-header bg-white">
          <button
            className="navbar-toggler"
            type="button"
            data-bs-toggle="collapse"
            data-bs-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent"
            aria-expanded="false"
            aria-label="Toggle navigation"
          >
            <span className="navbar-toggler-icon"></span>
          </button>
        </div>
        <div
          className="collapse navbar-collapse bg-white .d-none .d-sm-block .d-md-none"
          id="navbarSupportedContent"
        >
          <div className="title1">Title</div>

          <div className="title2">Title 2</div>
          <ul className="mr-auto mb-2 mb-lg-0">
            {<SidebarElement props={props} />}
          </ul>
        </div>
      </div>
    </div>

This is Sidebar CSS:

li {
  list-style-type: none;
}
.title1 {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.5px;
  padding-top: 24px;
  padding-left: 24px;
  padding-bottom: 28px;
  color: #336cfb;
}
.title2 {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 0.5px;
  padding-top: 24px;
  padding-left: 24px;
  padding-bottom: 20px;
  color: #52575c;
}
.active-link {
  color: #336cfb;
}
.sidebar-container {
  position: fixed;
  width: 242px;
  left: 0;
  overflow-x: hidden;
  overflow-y: auto;
  height: 100%;
  box-shadow: 5px 0 5px -5px #333;
}
.navbar-collapse {
  background: transparent;
  height: inherit;
  box-shadow: yellow;
}
.collapse {
  box-shadow: none;
}
#navbarSupportedContent {
  flex-direction: column;
  align-items: flex-start;
}

This is SidebarElement css:

.nav-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  width: 100%;
  padding-top: 8px;
  padding-bottom: 8px;
  font-family: "Roboto";
  font-style: normal;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  color: #52575c;
}
.customIcon {
  width: 18px;
  padding-right: 10px;
  color: #dbdde0;
}
li {
  list-style-type: none;
  padding: 14px 10px;
}
.active-link {
  color: #336cfb;
}

Answer №1

Issue with box shadow not being reset on the same element

The CSS code is read from top to bottom, causing the 'none' box-shadow to be immediately overridden.

.sidebar-container {
  position: fixed;
  width: 242px;
  left: 0;
  overflow-x: hidden;
  overflow-y: auto;
  height: 100%;
  box-shadow: 5px 0 5px -5px #333; /* Initial box shadow */
}

.navbar-collapse {
  background: transparent;
  height: inherit;
  box-shadow: none; /* Retains no box shadow */
}

.collapse {
  box-shadow: none; /* Removes box shadow */
}

#navbarSupportedContent {
  flex-direction: column;
  align-items: flex-start;
}

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

Unable to render JSON data using AJAX

I have a JSON file filled with various data and I'm trying to use AJAX to display it. Despite my efforts, I couldn't get it to work and after extensive research online, I decided to reach out for your assistance: $(document).ready(function ...

Tips on resizing images in CSS with accompanying text to prevent overlap

In my school project, I am using cloud9. When utilizing the live preview in a small window pane, my images appear correctly sized. However, upon maximizing my screen browser, the images stack on top of each other and their dimensions increase. My ideal l ...

Tips on adjusting the size of an HTML canvas specifically for the display

Currently, I am working on an innovative project utilizing HTML5 and canvas: The challenge at hand is to draw on a canvas with dimensions of 2200px/1600px (width/height), display it on my website in a smaller window sized at 600px/400px. However, post cli ...

What is the method for incorporating an upward arrow into a select element, while also including a downward arrow, in order to navigate through options exclusively with

I have a select element that I have styled with up and down arrows. However, I am seeking assistance to navigate the options dropdown solely using these arrows and hide the dropdown list. Here is the HTML: <div class="select_wrap"> <d ...

Styling your printed documents in Next.js 10

Within my Next 10 application, I am able to bring in global styles by importing them in _app.js in the following manner: import 'assets/css/app.css' I want to incorporate a print stylesheet as well. Instead of using a @media print { } query with ...

Setting up Bootstrap 4 in Laravel 5.7

Currently, I am faced with the task of compiling my app.scss file for a new Laravel project. However, I am hoping to integrate Bootstrap 4 into the project instead of relying on the default Bootstrap that comes with Laravel. Unfortunately, when running npm ...

conceal a component within a different container

Is there a way to hide or show an element within a container based on the hover state of another container? Here is an example of what I have tried so far: HTML5 <div class="left-menu-container"> <div class="left-menu-inner-container"> ...

Combining various components within an inactive element tag using Vue

I am working on creating expandable rows for a table element using this HTML code snippet. The current approach involves alternating between parent rows and multiple rows within tbody elements. <tbody class="js-table-sections-header">Parent row</ ...

Effect of Active or Focus on the HTML <ul> element

Check out this example of a UL tag: <ul style="list-style-type:none; padding:5px ; border:solid 1px #666666;"> <li>I am waiting </li> <li>I am waiting </li> <li>I am waiting </li> <li>I am wa ...

Having trouble with loading a background image from an external CSS file in Django

I am encountering an issue when attempting to load an image through external CSS on my Django project. While it works fine with inline CSS, I am curious as to why it fails with an external stylesheet. Any assistance on this matter would be greatly apprecia ...

Ways to update row background color based on specific column values

I need to customize the background color of my table rows based on the value in the "Category" column. For example: Name Category Subcategory A Paid B C Received D If the Category value is 'Paid', I want the ro ...

Is it possible to toggle all parent targets in Bootstrap?

When trying to showcase my point, I believe it is best demonstrated by visiting Bootstrap documentation at https://getbootstrap.com/docs/4.0/components/collapse/ and viewing the "multiple targets section." In this section, you will find three buttons: togg ...

Creating an interactive Bootstrap 4 accordion with Vue.js: Step-by-step guide

I am currently utilizing Bootstrap 4 (jQuery is also installed) to develop an accordion feature in combination with Vue.js The challenge I am facing is related to using the v-for directive on the card I intend to replicate for each item in a JSON file. Th ...

Guide on navigating to a specific section on a different page using scrolling

Adding a link for a "read more" button is simple. Just include the href attribute like this: <a href="about.html#post2">readmore</a> In my index.html page, I have implemented Bootstrap 3 with scroll animations for navbar sections. When clicki ...

Stop text from overflowing when it reaches the maximum width in flexbox

A basic flexbox layout is displayed with an image next to text, aiming for this layout: #container { align-items: center; background: black; display: flex; justify-content: center; padding: 10px; width: 500px; /* Dynamic */ } #image { bac ...

What is the purpose of activating hover styles when tapping on mobile devices?

On my button, you can see the color change when hovering: button { background-color: orange; } button:hover { background-color: darkorange; } Check out this example: https://jsfiddle.net/oepb5ks4/ While this works well on desktop, it's a diffe ...

Unique background image for every individual page

For my mobile app development using Jquery Mobile, I have implemented a custom theme but now want to vary the background images for different sections. My current code looks like this: .ui-overlay-a, .ui-page-theme-a, .ui-page-theme-a .ui-panel-wrapper { ...

Expanding SVG width upon import through Icomoon

After exporting an SVG file from Illustrator (already "Fit to selected Art"), I encountered an error while importing it via the Icomoon App. Strangely, other SVGs are importing correctly. I would appreciate any help or insight you can provide. Thank you i ...

When the browser width is reduced, the text appears outside of the image

When pasting text into an image in this example, everything looks fine at first. However, as the browser width is reduced, the text starts slipping out of the picture. To make matters worse, unsightly line breaks are also added. Is there a way to prevent ...