Accordion box shadow on body of the dropdown

Accordion box shadow on body of the dropdown



I am working on an accordion control for my site it nested inside a card I have added a box shadow to the header of the accordion which looks fine but when I expand it the body pops up with a shadow.
What I would like to figure out is a way to have the shadow on the body but not make it pop out when the accordion is expanded. I have set this example up




/* CSS used here will be applied after bootstrap.css */

.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">
accordian 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 -->
accordian body
<!-- End collapse panel content -->

</div>
</div>
</div>
</div>
</div>
</div>



Is there a way to fix this so that it is just one smooth transition so it looks like the box shadow is surrounding both elements when it is expanded?






Next time please convert your fiddles and bootplies into native SO snippets.

– Serg Chernata
Sep 12 '18 at 19:32




1 Answer
1



You sure can. Just apply the box shadow to their parent element. In this case, .post-card container.


.post-card




/* CSS used here will be applied after bootstrap.css */

.recent-posts
background: #D2C198;
/*margin-left: 400px;
margin-right: 400px; disabled because it looks bad in SO snippet*/


.post-card
background-color: #D2C198;
-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);


.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">
accordian 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 -->
accordian body
<!-- End collapse panel content -->

</div>
</div>
</div>
</div>
</div>
</div>






Thank you for the help !

– DRW
Sep 12 '18 at 22:38



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)