What is the method for adding a shadow solely on the right side while concealing the bottom border?

After creating a navigation bar with bootstrap, I wanted to make the active tab stand out above the others. Here's what I achieved:

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

Once I managed to connect the tabs with the content using a "before" class, everything looked good:

https://i.sstatic.net/3B2yf.png

However, when switching between tabs, there's a brief moment where the transition looks awkward:

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

Is there a way to fix this issue or hide the bottom shadow differently? I've tried using events like on hidden.bs.tab and shown.bs.tab without any luck so far.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
  <title></title>
  <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://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>

<style>
  ul.custom-nav-tab {
     border-bottom: 0px !important;
     margin-left: 20px;
     font-weight: 800;
  }
   ul.custom-nav-tab li a.active {
     background-color: #ffeed2 !important;
     border-color: #fff0 !important;
  }
   ul.custom-nav-tab li a {
     box-shadow: 1px 2px 7px 0 rgba(0, 0, 0, 0.3);
     padding: 15px 20px 15px 20px;
     color: inherit;
     border-radius: 10px 10px 0px 0px !important;
     background-color: #fef7ea !important;
  }
   div.custom-nav-tab {
     position: relative;
     border-radius: 10px;
     background-color: #ffeed2;
     padding: 20px;
     box-shadow: 1px 2px 7px 0 rgba(0, 0, 0, 0.3);
  }
   .custom-nav-active-tab {
     position: relative;
  }
   .custom-nav-active-tab:before {
     content: "";
     display: block;
     width: 100%;
     height: 15px;
     background-color: #ffeed2;
     position: absolute;
     bottom: -5px;
     left: 0;
     z-index: 10;
  }
</style>

<body>
<div class="container">
  <div class="row">
    <div class="col-12">
      <ul class="nav nav-tabs custom-nav-tab" id="myTab" role="tablist">
        <li class="nav-item">
          <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Hotel + Activity</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Hotel</a>
        </li>
      </ul>
      <div class="tab-content custom-nav-tab" id="myTabContent">
        <div class="tab-pane fade show active tab1" id="home" role="tabpanel" aria-labelledby="home-tab"> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut varius varius turpis at consequat. Suspendisse potenti. Vestibulum sagittis eget enim non dapibus. Nam luctus lectus nulla, eget convallis libero ultrices nec. Duis feugiat ex ut nunc mollis facilisis. Proin eu lacus sed justo cursus condimentum id at mi. Aliquam erat volutpat.</p></div>
        <div class="tab-pane fade tab2" id="profile" role="tabpanel" aria-labelledby="profile-tab"> <p>xxxxxDonec mattis laoreet suscipit. Donec blandit quam sed justo mattis, et hendrerit leo sodales. Donec elit leo, sollicitudin sed purus vitae, iaculis iaculis lacus. Proin quis leo a purus gravida ultricies. Nam molestie a nisi sed scelerisque. Proin in suscipit sem, in viverra libero. Proin quam diam, consequat vitae arcu eget, egestas ultrices eros. Donec sed fermentum lorem. Nam dolor sem, aliquam dapibus rutrum id, tempor ac leo. Vestibulum in neque id eros tristique lacinia. Duis a bibendum dolor, nec cursus eros. Morbi quis enim eu quam gravida lacinia. Etiam tincidunt venenatis felis quis pellentesque. Sed sagittis elit vitae arcu malesuada, quis dapibus libero porttitor.
          </p></div>
      </div>
    </div>
  </div>
</div>

<script>
  $(document).ready(function() {
    $(".nav-item:has(a.active)").addClass("custom-nav-active-tab");
  });

  $('a[data-toggle="tab"]').on('hidden.bs.tab', function (e) {
      $(".nav-item, a").not(".active").removeClass("custom-nav-active-tab");
      $("..nav-item:has(a.active)").addClass("custom-nav-active-tab");
  });
</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://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
</body>
</html>

Answer №1

Utilize the pseudo element technique on the a and opt for using inherit as the background color value. This method will minimize or mask any negative effects.

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

Achieving Content Alignment Using CSS

I successfully implemented a design on my HTML page that divides it into three sections vertically, with each section having a different background color - white, gray, and black. The backgrounds stretch the full width of the page regardless of screen reso ...

The setState function has not been called

I am facing an issue where my setState method is not getting invoked. Even after setting the state, the value remains at the default value when printed. This problem occurs while using Expo. Here is my code snippet: import React from 'react'; ...

Vue - making one element's width match another element's width

Trying to dynamically adjust the innermost element's width to match the outermost element's width with Vue: <div id="banner-container" class="row"> <div class="col-xs-12"> <div class="card mb-2"> <div ...

The issue of for loops malfunctioning in JavaScript when using a variable declared in Node.js and passed to Jade

Currently, I am delving into the world of node.js and JADE but seem to be encountering a challenge when it comes to implementing a for loop within a JavaScript block in a jade file. My approach involves experimenting with a basic code where I pass an array ...

Modify the table layout by incorporating images within separate div containers for each row

In my layout, there is a grey box element that contains a table with rows of small images. I want the table to automatically adjust based on the number of images so that when the grey box reaches its maximum size, the images move to the next row. Is this a ...

When I use `console.log` with `req.body` in Node, the password is

Currently, I am utilizing NodeJs on the backend to console.log(req.body) data from a form that gathers usernames and passwords from users. I have noticed that this method exposes the collected username and password information. Should I be concerned abou ...

Guide on displaying a dropdown in AngularJS when the select option is already applied but not showing

I am currently working on creating a select option using JSON data, but for some reason it is not displaying. I have used the select tag and placed the option tags inside it. <div ng-switch-when="SWITCH"> <select name="selectedFacilit ...

The optimal approach for AngularJS services and promises

I have a unique setup in my AngularJS application where I utilize services to make API calls using $http and handle promises in my controllers. Here's an example of my current approach: app.service('Blog', function($http, $q) { var deferr ...

VeeValidate3: Unique validation will always return true upon submission

I have integrated Vue.js 2 and VeeValidate3 to validate my form. In addition, the form makes an axios call to verify if the username is already in use. If it is, the validation should be set to false. Everything seems to be working fine so far. I am able ...

Divide Chinese Characters

Is there a way to split foreign characters like Chinese into separate array values using JavaScript? While the split() function works well with English, it doesn't seem to handle Chinese characters properly. Take a look at the results from two string ...

Expanding a grid cell beyond 100% can be achieved using a 1

I am working with a grid layout that I want to span exactly the height of the screen - no more, no less. The grid includes a fixed header (one), a fixed footer (three), and scrollable content (two). .grid-container { display: grid; grid-template-a ...

Ways to retrieve child state in React?

After creating my own form component with a render() method that looks like this: render() { return ( <form onSubmit={this.onSubmit} ref={(c)=>this._form=c}> {this.props.children} </form> ) } I enabled ...

How can I connect an image to a link in Vue.js?

I am having trouble linking to another URL when I click on an image using Vue. It should be possible to link by clicking on the images, but it seems to not be working. If anyone can offer assistance, I would greatly appreciate it. Below is what my code ...

What is the best way to bring a function into another function from a separate file?

I am attempting to call the "changenavitemstate" function from the "Navbarlink" file. When I try to import the function into the file, I encounter an error. I have tried using props to access the function but have been unsuccessful. ...

Why does jQuery not work when attempting to access the HTML of paragraphs within the main content using $('#main-content').children('p'

Hello, I'm still getting the hang of jQuery and Stack Overflow. I'm having trouble understanding the differences between DOM elements. My goal is to update the innerHTML of the <p> element, but I'm encountering some unexpected behavior ...

How can you effectively manage the latest "Bootstrap Toast" functionality in Angular version 7 and above?

Struggling to integrate Bootstrap 4.2 Toast into an Angular 7 application. The provided Jquery sample from the Bootstrap documentation is challenging to translate into Angular. Currently, relying on Jquery within the HTML template to call $('.toast&a ...

Implementing AngularJS html5mode alongside nodeJS and Express

Currently, my AngularJS application is being served by a nodeJS server with Express. Everything runs smoothly when using the default angularJS routes (hashbangs); however, I am now attempting to enable html5 mode. To activate html5mode, I have implemented ...

Sending a cookie token to the server through the header

This is my first attempt at working with a server Utilizing React and express Storing token in browser cookie from the server //Upon login request res.cookie('token', token, {maxAge: 3600000} ).json({ user: userDoc, message: 'message!&apos ...

The "events" module could not be resolved in React-Native

The server encountered an internal error: 500 URL: Body: {"message":"There was an issue resolving the module events from the specified directory. This may be due to a module not existing in the module map or directories listed.","name":"UnableToResolveEr ...

Is there a way to disable a dropdown menu when clicking on a different one?

[![ Dashboard Admin Admin Profile Change Password Doctors Doctors List Doctors Appointments Doctors Requests Add a Doctor Patients ...