0

I am creating a tab based system where you can add days and add information for each day. I am trying to achieve an overlapping look when it comes to the tabs and would like to add a sort of shadow like effect when a tab is being overlapped by another on the left side. In this specific example, when day one is active, day 2's inner left portion will have a bit of a shadow to make it look like it is being overlapped. How can I achieve this effect?

.breakout-holder {
  width: 100%;
  border: 1px solid black;
}

.heading {
  /* background-color: grey; */
  height: 40px;

  display: flex;
  align-items: flex-end;
}

.active {
  background-color: lightgreen !important;

  /* box-shadow: inset 0 20px 20px -20px #000000; */
  z-index: 5000;
}

.tab {
  font-weight: bold;
  background-color: lightgrey;
  color: black;

  height: 90%;
  width: auto;
  padding: 0 20px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px solid black;
  border-right: 1px solid black;
  border-left: 1px solid black;

  border-radius: 15px 15px 0 0;

  cursor: pointer;
}

.tab:not(:first-child) {
  margin-left: -5px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="breakoutStyle.css">
    <title>Breakout room form</title>
</head>
<body>
    <div class="breakout-holder">
        <div class="heading">
            <div class="tab active">
                Day 1
            </div>
            <div class="tab">
                Day 2
            </div>
            <div class="tab" style="z-index: -10">
                +
            </div>
        </div>
        <div class="body"></div>
    </div>
</body>
<script src="app.js"></script>
</html>

I have tried adding in a box shadow to the tab elements that are on top of another tab. This method did not work as it looks a little cheap in my opinion.

Here is the css I tried to add to the tab css class

-webkit-box-shadow: 34px 0px 25px -13px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 34px 0px 25px -13px rgba(0, 0, 0, 0.75);
  box-shadow: 34px 0px 25px -13px rgba(0, 0, 0, 0.75);
react_or_angluar
  • 1,568
  • 2
  • 13
  • 20
klaurtar1
  • 700
  • 2
  • 8
  • 29
  • Take a look at this question https://stackoverflow.com/questions/39809238/how-can-i-make-box-shadow-show-over-the-next-element-in-a-container – Scurgery Dec 21 '20 at 23:10

4 Answers4

2

Add this to the active tab: box-shadow: 2px 1px 2px 1px rgba(0, 0, 0, 0.4);

.breakout-holder {
  width: 100%;
  border: 1px solid black;
}

.heading {
  /* background-color: grey; */
  height: 40px;

  display: flex;
  align-items: flex-end;
}

.active {
  background-color: lightgreen !important;

  box-shadow: 2px 1px 2px 1px rgba(0, 0, 0, 0.4); 
  z-index: 5000;
}

.tab {
  font-weight: bold;
  background-color: lightgrey;
  color: black;

  height: 90%;
  width: auto;
  padding: 0 20px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px solid black;
  border-right: 1px solid black;
  border-left: 1px solid black;

  border-radius: 15px 15px 0 0;

  cursor: pointer;
}

.tab:not(:first-child) {
  margin-left: -5px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="breakoutStyle.css">
    <title>Breakout room form</title>
</head>
<body>
    <div class="breakout-holder">
        <div class="heading">
            <div class="tab active">
                Day 1
            </div>
            <div class="tab">
                Day 2
            </div>
            <div class="tab" style="z-index: -10">
                +
            </div>
        </div>
        <div class="body"></div>
    </div>
</body>
<script src="app.js"></script>
</html>
kmp
  • 692
  • 6
  • 17
2

You can use pseudo elements for this, but the caveat is you can't use a negative z-index because of the stacking context and the need for the active tab to be above the other tabs.

This is basically using the box-shadow and the transform: skew to fake either side of the active tab.

Then I have styles for the first and last active tabs so the :before and :after, respectively, do not show up if either are active.

This approach gives you a little more of a "polished" look instead of just using box-shadow on the active tab.

.breakout-holder {
  width: 100%;
  border: 1px solid black;
}

.heading {
  /* background-color: grey; */
  height: 40px;
  display: flex;
  align-items: flex-end;
  position: relative;
}

.tab.active {
  position: relative;
  background-color: lightgreen !important;
  z-index: 5;
}

.tab {
  position: relative;
  font-weight: bold;
  background-color: lightgrey;
  color: black;
  height: 90%;
  width: auto;
  padding: 0 20px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px solid black;
  border-right: 1px solid black;
  border-left: 1px solid black;
  border-radius: 15px 15px 0 0;
  cursor: pointer;
}

.tab:not(:first-child) {
  margin-left: -5px;
}

.tab::before,
.tab::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 2px;
  box-shadow: -3px 0px 4px 1px rgba(0, 0, 0, .3);
  transform: skew(-5deg,-10deg);
  width: 1px;
  height: 60%;
  border-radius: 0;
  display: none;
}

.tab::after {
  left: auto;
  right: 0;
  box-shadow: 3px 1px 4px 1px rgba(0, 0, 0, .3);
  transform: skew(5deg,10deg);
}

.tab.active::before,
.tab.active::after {
  z-index: -1;
  display: block;
}

.tab.active:first-child::before {
  display: none;
}

.tab.active:last-child::after {
  display: none;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <link rel="stylesheet" href="breakoutStyle.css">
  <title>Breakout room form</title>
</head>

<body>
  <div class="breakout-holder">
    <div class="heading">
      <div class="tab">
        Day 1
      </div>
      <div class="tab active">
        Day 2
      </div>
      <div class="tab">
        +
      </div>
    </div>
    <div class="body"></div>
  </div>
</body>
<script src="app.js"></script>

</html>
disinfor
  • 10,865
  • 2
  • 33
  • 44
0

.breakout-holder {
  width: 100%;
  border: 1px solid black;
}

.heading {
  /* background-color: grey; */
  height: 40px;

  display: flex;
  align-items: flex-end;
}

.active {
  background-color: lightgreen !important;
  -webkit-box-shadow: 0px 10px 4px -2px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 10px 4px -2px rgba(0,0,0,0.75);
  box-shadow: 0px 10px 4px -2px rgba(0,0,0,0.75);
  z-index: 5000;
}

.tab {
  font-weight: bold;
  background-color: lightgrey;
  color: black;

  height: 90%;
  width: auto;
  padding: 0 20px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px solid black;
  border-right: 1px solid black;
  border-left: 1px solid black;

  border-radius: 15px 15px 0 0;

  cursor: pointer;
}

.tab:not(:first-child) {
  margin-left: -5px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="breakoutStyle.css">
    <title>Breakout room form</title>
</head>
<body>
    <div class="breakout-holder">
        <div class="heading">
            <div class="tab active">
                Day 1
            </div>
            <div class="tab">
                Day 2
            </div>
            <div class="tab" style="z-index: -10">
                +
            </div>
        </div>
        <div class="body"></div>
    </div>
</body>
<script src="app.js"></script>
</html>
react_or_angluar
  • 1,568
  • 2
  • 13
  • 20
0

It would be nice if you could link some examples of what you are going for, but something you can possibly do is this:

/*   background-image: linear-gradient(#134C13, #66AF66, lightgreen); */
  
  .breakout-holder {
  width: 100%;
  border: 1px solid black;
}

.heading {
  /* background-color: grey; */
  height: 40px;

  display: flex;
  align-items: flex-end;
}



.tab {
  font-weight: bold;
  background-color: lightgrey;
  color: black;
  height: 90%;
  width: auto;
  padding: 0 20px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px solid black;
  border-right: 1px solid black;
  border-left: 1px solid black;

  border-radius: 15px 15px 0 0;

  cursor: pointer;
}


.active {
  background-color: lightgreen !important;
  border-right: 5px solid black;
  border-bottom: 2px solid black;
  /* box-shadow: inset 0 20px 20px -20px #000000; */
  z-index: 5000;
}

.tab:not(:first-child) {
  margin-left: -5px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="breakoutStyle.css">
    <title>Breakout room form</title>
</head>
<body>
    <div class="breakout-holder">
        <div class="heading">
            <div class="tab active">
                Day 1
            </div>
            <div class="tab">
                Day 2
            </div>
            <div class="tab" style="z-index: -10">
                +
            </div>
        </div>
        <div class="body"></div>
    </div>
</body>
<script src="app.js"></script>
</html>
John
  • 5,132
  • 1
  • 6
  • 17