【问题标题】:How can I change the background color of Bootstrap modal?如何更改 Bootstrap 模态的背景颜色?
【发布时间】:2022-03-06 19:21:41
【问题描述】:

正如标题所示,我想更改实际模态的颜色,而不是模态后面的阴影区域。正如post 所说。我只想更改模态的颜色。下面是一些代码:

<div class="portfolio-modal modal fade" id="HighSchoolModal" tabindex="-1" role="dialog" aria-hidden="true" style="background-color:#F07A1A !important;">
        <div class="modal-content">
            <div class="close-modal" data-dismiss="modal">
                <div class="lr">
                    <div class="rl">
                    </div>
                </div>
            </div>
            <div class="container">
                <div class="row">
                    <div class="col-lg-8 col-lg-offset-2">
                        <div class="modal-body">
                            <h2>Parktown Boys' High</h2>
                            <hr class="star-primary">
                            <img src="img/portfolio/park.jpg" class="img-responsive img-centered" style="width:50%" alt="">
                            <p>Use this area of the page to describe your project. The icon above is part of a free icon set by <a href="https://sellfy.com/p/8Q9P/jV3VZ/">Flat Icons</a>. On their website, you can download their free set with 16 icons, or you can purchase the entire set with 146 icons for only $12!</p>
                            <ul class="list-inline item-details">
                                <li>Client: <strong><a href="http://startbootstrap.com">Start Bootstrap</a></strong>
                                </li>
                                <li>Date: <strong><a href="http://startbootstrap.com">April 2014</a></strong>
                                </li>
                                <li>Service: <strong><a href="http://startbootstrap.com">Web Development</a></strong>
                                </li>
                            </ul>
                            <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-times"></i> Close</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

我在代码中使用了style="background-color:#F07A1A !important;",在 chrome 元素检查器中它显示颜色正在被应用:

问题...我的模态仍然是白色的。有什么想法可以改变背景颜色吗?

【问题讨论】:

    标签: html css twitter-bootstrap


    【解决方案1】:

    将样式应用于.modal-content

    【讨论】:

      【解决方案2】:
      $(".modal").on('shown.bs.modal', function() {
        $('.modal-backdrop').css('background', '#00000073');
      });
      

      【讨论】:

      • 如果您可以添加解释为什么这会回答问题,那就更好了。这也是一个 jquery 示例,而帖子似乎正在寻找一个 css 示例
      猜你喜欢
      • 1970-01-01
      • 2013-10-16
      • 2013-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多