html - 向 Bootstrap 主题 (CSS) 添加边框不起作用

标签 html css twitter-bootstrap image border

我想为我的 img 添加一个常规阴影,当我使用以下代码时,一切正常:

img.img-border {
    -webkit-box-shadow: 10px 10px 41px -12px rgba(123,129,140,1);
    -moz-box-shadow: 10px 10px 41px -12px rgba(123,129,140,1);
    box-shadow: 10px 10px 41px -12px rgba(123,129,140,1); }
<html>
    <head>
        <link href="style.css" rel="stylesheet" type="text/css" media="all">
    </head>
    <body>
        <img class="img-border" src="https://placeholdit.co/i/200x150">
    </body>
</html>

但是当我在 Bootstrap 主题中执行相同操作时,img 没有任何反应。有人有想法吗?这是 Bootstrap 部分代码:

<head>
    <link href="css/bootstrap-theme.css" rel="stylesheet" type="text/css" media="all" />
    <link href="css/custom.css" rel="stylesheet" type="text/css" media="all" />
</head>

<body>
    <section class="pb16">
        <div class="container">
            <div class="row v-align-children">
                 <div class="col-md-4 col-sm-5 mb-xs-24">
                     <h3 class="large mb40 mb-xs-16">TITLE BLABLA</h3>

                     <p class="lead" style="text-align: justify">Text Content blablabla</p>
                    <a class="btn btn-filled btn-lg mb32 mt-xs-40" href="#">Click Here</a>
                    </div>
                    <div class="col-md-7 col-md-offset-1 col-sm-6 col-sm-offset-1 text-center" >
            <img class="img-shadow" alt="Screenshot" src="img/picture.png">
                </div>
            </div>
            <!--end of row-->
        </div>
        <!--end of container-->
    </section>

这是在 custom.css 中:

  html.body.img.img-shadow {
    -webkit-box-shadow: 10px 10px 41px -12px rgba(123,129,140,1);
    -moz-box-shadow: 10px 10px 41px -12px rgba(123,129,140,1);
    box-shadow: 10px 10px 41px -12px rgba(123,129,140,1);
  }

最佳答案

听起来您的 CSS 不够具体,无法覆盖 Bootstrap CSS。

尝试在图像标签前添加一些父类/元素,看看是否可行。

例如

html body img.img-border {
    -webkit-box-shadow: 10px 10px 41px -12px rgba(123,129,140,1);
    -moz-box-shadow: 10px 10px 41px -12px rgba(123,129,140,1);
     box-shadow: 10px 10px 41px -12px rgba(123,129,140,1); 
}

您也可以在末尾使用 !important 强制启用样式,但这是不好的做法,因此请仅在绝对必要时才使用它。

关于html - 向 Bootstrap 主题 (CSS) 添加边框不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48668184/

相关文章:

html - 如何为 three.js 生成支持 Unicode 的字体文件?

javascript - 如何存储包含参数的 JS 函数引用

html - svg 为什么 dasharray 没有按预期工作

css - Bootstrap 不适用于开发中的 Rails 4.2.4 应用程序

javascript - data-dismiss ="modal"关闭 MVC 局部 View 中同一页面上所有打开的模态对话框

javascript - 在移动设备上按回车键后“.blur”输入并隐藏键盘

html - 使用 VBA 以 HTML 形式通过 &lt;input\input> 上传文件

javascript - 点击元素方式的图片

c# - 图像上的文字 css(略有不同)

html - MVC 3 的 CSS url 路径不正确