【问题标题】:How to fix section background color如何修复部分背景颜色
【发布时间】:2019-04-24 07:07:13
【问题描述】:

对于我之前在这篇文章中的错误,我深表歉意。我无法理解为什么我的 Small-bio 部分的背景颜色没有改变。我觉得这与引导轮播有关,但 idk。我希望能够理解我做错了什么以及如何避免这种情况再次发生。任何帮助将不胜感激。

谢谢

我已经尝试更改其他部分的颜色和高度,并且我已经移动了样式表。

    <!DOCTYPE html>
    <html lang="en" dir="ltr">

    <head>
      <meta charset="utf-8">
      <title>Bagwell Productions</title>

      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="viewport" content="height=device-height, initial-scale=1.0">
      <!-- Google Font -->
      <link href="https://fonts.googleapis.com/css?family=Montserrat|Ubuntu" rel="stylesheet">

      <!-- CSS & bootstrap stylesheet -->
      <link rel="stylesheet" href="Bagwell\style.css">
      <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">


      <!-- JS -->
      <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
      <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>





    </head>

    <body>


      <section id="navbar">
        <!-- Nav Bar -->

        <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
          <a class="navbar-brand" href="#">Bagwell Productions</a>
          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
            <div class="navbar-nav ml-auto">
              <a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
              <a class="nav-item nav-link" href="#">Gallery</a>
              <a class="nav-item nav-link" href="#">About Me</a>
              <a class="nav-item nav-link" href="#">Contact Me</a>
            </div>
          </div>
        </nav>
      </section>



      <section id="slideshow">


        <!-- slideshow -->
        <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
          <div class="carousel-inner">
            <div class="carousel-item active">
              <img src="C:\Users\ghost\Desktop\Projects\Bagwell\wetransfer-876787\126A0171.JPG" alt="league of extraordinary women" style="width:100%" style="height:auto" ; class="d-block w-100">
            </div>
            <div class="carousel-item">
              <img src="C:\Users\ghost\Desktop\Projects\Bagwell\wetransfer-876787\IMG_3732.JPG" alt="Grad Pics" style="width:100%" ; style="height:auto" class="d-block w-100">
            </div>
            <div class="carousel-item">
              <img src="C:\Users\ghost\Desktop\Projects\Bagwell\wetransfer-95bb54\IMG_9997.JPG" alt="pit bull" style="width:100%;" style="height:auto" "class=" d-block w-100"">
            </div>
            <div class="carousel-item">
              <img src="C:\Users\ghost\Desktop\Projects\Bagwell\wetransfer-95bb54\IMG_7098.JPG" style="width:100%;" style="height:auto" class="d-block w-100">
            </div>
            <div class="carousel-item">
              <img src="C:\Users\ghost\Desktop\Projects\Bagwell\wetransfer-876787\IMG_1938.JPG" alt="walking" style="width:100%;" style="height:auto" class="d-block w-100">
            </div>
            <div class="carousel-item">
              <img src="C:\Users\ghost\Desktop\Projects\Bagwell\wetransfer-876787\IMG_1749.JPG" alt="nasa grad" style="width:100%;" style="height:auto" class="d-block w-100">
            </div>
          </div>
          <!-- controls for slideshow -->
          <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only">Previous</span>
          </a>
          <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
          </a>
        </div>
      </section>

        <!-- Small intro -->
      <section id="small-bio">

        <div class="Bottom-intro">
          <h3>Welcome to the photography portfolio of William Bagwell. the Gallery's in this website showcase professional work in different settings.</h3>



        </div>

      </section>
    </body>

    </html>

    #small-bio{
      background-color: blue  !important;
    }
    #slideshow{
      overflow: hidden;
    }

    #slideshow{
      overflow: auto;

    }

    }
    h3{
    background-color: blue;
    }

    .carousel-inner{
      overflow: ;
      padding-bottom: 7%;
      background-color: red;
      overflow: hidden;
    }
    .Bottom-intro{
      position: relative;
      overflow: hidden;
      height: 300px;
      width: 100%;
      color:#fff;
      background-color: #ef8172;
      text-align: center;
    }

```





【问题讨论】:

  • I have a div that's background color isn't changing jsfiddle.net/AndrewL64/4m52k8vf

标签: html css bootstrap-4


【解决方案1】:

查看你的 style.css 链接

<link rel="stylesheet" href="Bagwell\style.css">

改成

  <link rel="stylesheet" href="Bagwell/style.css">

有帮助吗

【讨论】:

  • 感谢您的输入@ahad 但是,这没有效果。
【解决方案2】:

您正在尝试将背景颜色设置为图像占用 100% 容器空间(即 carousel-inner)的轮播。

如果您想要容器的背景颜色,请将图像的大小减小到 80%,并为图像设置 margin: 0 auto 以便它们可以居中对齐。

您还提到了图像的冗余宽度,1) 通过添加 w-100,2) 通过使用内联宽度。使用任何一种。而且您在元素中使用了 2 个样式标签,这是不正确的。

例如使用内联样式

&lt;img src="C:\Users\ghost\Desktop\Projects\Bagwell\wetransfer-95bb54\IMG_7098.JPG" style="width:80%; margin: 0 auto; height: auto" class="d-block"&gt;

例如使用引导类

&lt;img src="C:\Users\ghost\Desktop\Projects\Bagwell\wetransfer-95bb54\IMG_7098.JPG" style="height:auto" class="d-block w-75 mx-auto"&gt;

为每个图像标签执行此操作,您的图像后面应该有一个背景颜色。

【讨论】:

  • lyer 非常感谢您的帮助。所以我使用你提到的引导类更改了我的图像。图像确实居中对齐,但背景颜色仍然不会改变。
  • 哈哈,是的,我以为你的轮播有问题。好吧,在您的#small-bio 样式中,背景颜色蓝色和 !important 之间有一个空格。删除它,这应该可以工作。 IE。背景颜色:蓝色!重要;
  • lyer 很遗憾仍然没有变化。
  • 如果你检查你的css,还有一个额外的'}'结束花括号。您可以尝试删除它吗?
  • lyer 我删除了 } 仍然没有。我最终删除了除 .carousel-inner 之外的所有 css 和。底部介绍,它仍然没有改变。它必须与覆盖我的 css 的轮播有关,但我知道如何。
猜你喜欢
  • 2014-11-15
  • 1970-01-01
  • 2019-12-20
  • 1970-01-01
  • 2014-07-08
  • 2022-08-22
  • 2012-12-14
  • 2011-11-29
  • 1970-01-01
相关资源
最近更新 更多