Bootstrap删除Nav&之间的1px填充/间隙旋转木马/格

时间:2016-03-03 18:17:16

标签: html css twitter-bootstrap

我正试图消除Navbar和Carousel之间的差距。 但是,我不能为我的生活找出导致差距的因素以及如何解决这个问题。

/ *这里使用的CSS将在bootstrap.css * /

之后应用
      .navbar {
          margin: 0; /*add this*/
          padding: 0px;
      }

      .navbar-default {
          background-color: #ffffff;
      }

      /* title */
      .navbar-default .navbar-brand {
          color: #000000;
      }

      .navbar-default .navbar-brand:hover,
      .navbar-default .navbar-brand:focus {
          color: #808080;
      }

      /* link */
      .navbar-default .navbar-nav > li > a {
          color: #000000;
      }
      .navbar-default .navbar-nav > li > a:hover,
      .navbar-default .navbar-nav > li > a:focus {
          color: #808080;
      }

      /* active link */

      .navbar-default .navbar-nav > .active > a, 
      .navbar-default .navbar-nav > .active > a:hover, 
      .navbar-default .navbar-nav > .active > a:focus {
          color: #ffffff;
          background-color: #000000;
      }

      .navbar-default .navbar-nav > .open > a, 
      .navbar-default .navbar-nav > .open > a:hover, 
      .navbar-default .navbar-nav > .open > a:focus {
          color: #555;
          background-color: #ff0000;
      }

      /* caret */
      .navbar-default .navbar-nav > .dropdown > a .caret {
          border-top-color: #777;
          border-bottom-color: #777;
      }
      .navbar-default .navbar-nav > .dropdown > a:hover .caret,
      .navbar-default .navbar-nav > .dropdown > a:focus .caret {
          border-top-color: #333;
          border-bottom-color: #333;
      }
      .navbar-default .navbar-nav > .open > a .caret, 
      .navbar-default .navbar-nav > .open > a:hover .caret, 
      .navbar-default .navbar-nav > .open > a:focus .caret {
          border-top-color: #555;
          border-bottom-color: #555;
      }
      /* mobile version */
      .navbar-default .navbar-toggle {
          border-color: #DDD;
      }
      .navbar-default .navbar-toggle:hover,
      .navbar-default .navbar-toggle:focus {
          background-color: #DDD;
      }
      .navbar-default .navbar-toggle .icon-bar {
          background-color: #CCC;
      }
      @media (max-width: 767px) {
          .navbar-default .navbar-nav .open .dropdown-menu > li > a {
              color: #777;
          }
          .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,
          .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
              color: #333;
          }
      }

      .container {
        padding-top: 0px !important;
        padding-bottom: 0px !important;
        margin-top: 0px !important;
        margin-bottom: 0px !important;
      } 

        <div class="container">

            <div class="navbar-header">
                <a class="navbar-brand" href="#">Progression</a>
                <a class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                </a>
            </div>

            <div class="navbar-collapse collapse">
              <ul class="nav navbar-nav">
                <li class="active"><a href="#">Home</a></li>
                <li><a href="#">Physio</a></li>
                <li><a href="#">Massage</a></li>
                <li><a href="#">Beauty</a></li>
                <li><a href="#">First Aid</a></li>
              </ul>
            </div>

        </div>

    </nav>

                <!-- Carousel -->

    <div class="container">
        <div class="row">
            <div class="col-sm-12>

                <div id=" my-slider"="" data-ride="carousel">

                    <!-- indicators dot nav -->


                    <!-- wrapper for slides -->
                    <div class="carousel-inner" role="listbox">

                        <div class="item active">
                            <img src="https://lh5.googleusercontent.com/-WHXl1TAoHoQ/VsW7_mHWeQI/AAAAAAAAAEQ/nzQm8w62c3s/w1310-h524-no/Progression_Massage_Budha.png" alt="Physio Massage Val d'Isere">
                            <div class="carousel-caption">
                                <h2>Massage</h2>
                                <h4>Relaxation to Deep Tissue</h4>
                            </div><!-- end carousel caption -->
                        </div>

                        <div class="item">
                            <img src="https://lh4.googleusercontent.com/-lj7DIStRI8M/VthrRPFcQFI/AAAAAAAAAFY/2ynRLjTZTnI/w1310-h524-no/Progression_Beauty_Therapies.png" alt="Beauty Treatments Nails Facials &amp; Waxing Val d'Isere">
                            <div class="carousel-caption">
                                <h2>Beauty</h2>
                                <h4>Nails - Facials - Waxing</h4>
                            </div>
                        </div>

                        <div class="item">
                            <img src="https://lh4.googleusercontent.com/-aCIY16PFylg/VsW6L-YwpqI/AAAAAAAAADA/wSTG1QlJLqY/w1310-h524-no/Progression_Val_dIsere.png" alt="Physiotherapy Assesment Treatment Rehab Val d'Isere">
                            <div class="carousel-caption">
                                <h2>Physiotherapy</h2>
                                <h4>Assesment Treatment Rehab</h4>
                            </div>
                        </div>

                    </div>              

                </div>

            </div>
        </div>

http://www.bootply.com/jbTugk4aPV

1 个答案:

答案 0 :(得分:1)

实际上,它不是1像素的间隙,而是css中的边界navbar.less行号。 15。

这是你的css

.navbar {
    position: relative;
    min-height: 50px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

请记住它的css文件代码不在其中的边界处创建该间隙,您可以通过在文件中键入另一个css来覆盖它。

.navbar{
   border:none!important;
} 

或者您只需将border-width设置为0px

即可
.navbar-static-top { 
   z-index: 1000; 
   border-width: 0px;
 } 

删除1px白色导航栏边框。