简体   繁体   English

将 box-shadow 应用于 Bootstrap 4 卡片组件

[英]Applying box-shadow to Bootstrap 4 card component

I'm trying to apply a simple shadow to a cards component.我正在尝试将简单的阴影应用于卡片组件。 Somehow the shadow glitches and looks mirrored and misplaced.不知何故,阴影出现故障,看起来像镜像和错位。

I think it has to do with margin-bottom but there's more to it I can't figure out.我认为这与margin-bottom有关,但还有更多我无法弄清楚。

What is the correct approach to let cards have a shadow?让卡片有阴影的正确做法是什么?

https://jsfiddle.net/qdjeuo65/ https://jsfiddle.net/qdjeuo65/

<style>
    .card {
      box-shadow: 0 0 10px 0 rgba(100, 100, 100, 0.26);
    }
    
</style>

<div class="card-columns">
    <div class="card">
        <div class="card-body">
            <div class="card-title">title</div>
            <div class="card-text">
                body
            </div>
        </div>
        <div class="card-footer">
            footer
        </div>
    </div>

    <div class="card">
        <div class="card-body">
            <div class="card-title">title</div>
            <div class="card-text">
                body
            </div>
        </div>
        <div class="card-footer">
            footer
        </div>
    </div>

    <div class="card">
        <div class="card-body">
            <div class="card-title">title</div>
            <div class="card-text">
                body
            </div>
        </div>
        <div class="card-footer">
            footer
        </div>
    </div>
</div>

My browser is Chrome 84.我的浏览器是 Chrome 84。

在此处输入图像描述

The problem causes the column-count css property that you use on the card-columns class.该问题导致您在card-columns class 上使用的column-count css 属性。 You can align cards with flex or add transform: translateZ(0);您可以使用 flex 对齐卡片或添加transform: translateZ(0); to the .card class as a workaround..card class 作为解决方法。

Please add display: flex;请添加display: flex; property to .card-columns . .card-columns属性。 That will solve your problem.这将解决你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM