I've been developing an accordion control for my website that is nested inside a card. I have applied a box shadow to the header of the accordion which looks fine, but when it expands, the body pops up with a shadow as well. I'm trying to figure out a solution where the shadow remains on the body without popping out when the accordion is expanded. Here's an example I've set up:
/* Custom CSS styles */
.recent-posts {
background: #D2C198;
margin-left: 400px;
margin-right: 400px;
}
.post-card {
background-color: #D2C198;
}
.reply-link,
.reply-link:hover,
.reply-link:active,
.reply-link:visited,
.user-post,
.user-post:hover,
.user-post:active,
.user-post:visited {
color: #222222;
text-decoration: none !important;
}
.card-header {
-webkit-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-moz-box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.post-body {
-webkit-box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
-moz-box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.post-reply {
padding-bottom: 10px;
}
.forum-image {
border-radius: 50%;
width: 100px;
height: 100px;
object-fit: cover;
}
.post-header {
padding-left: 30px;
height: 25px;
margin-left: 86px;
}
.post-divider {
border-bottom: 1px solid #222;
padding-top: 5px;
}
.avatar {
width: 50px;
height: 50px;
border-radius: 50%;
}
.header-forum-badge {
float: left;
}
.post-info {
padding-top: 10px;
}
.user-post {
display: inline-flex;
margin-left: 14px;
}
.user-post-avatar {
margin-right: 12px;
}
.post-views-replies {
float: right;
text-align: right;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="card recent-posts">
<div class="card-body">
<div id="post-accordian">
<div class="card post-card">
<div class="card-header" id="post-heading" onmouseover="" data-toggle="collapse" data-target="#post-collapse" aria-expanded="true" aria-controls="post-collapse">
Accordion Header
</div>
<!-- Collapse panel -->
<div id="post-collapse" class="collapse post-container" aria-labelledby="post-heading" data-parent="#post-accordian">
<div class="card-body post-body">
<!-- collapse panel content -->
Accordion Body
<!-- End collapse panel content -->
</div>
</div>
</div>
</div>
</div>
</div>
Is there a way to create a smooth transition so it appears like the box shadow surrounds both elements when the accordion is expanded?