如何显示另一个div?

时间:2017-03-22 08:24:02

标签: html css z-index

我有这个旋转木马,我无法覆盖英雄文本。

这是html / css:

/********************************/


/*       Fade Bs-carousel       */


/********************************/

.fade-carousel {
  position: relative;
  height: 850px;
}

.fade-carousel .carousel-inner .item {
  height: 1000px;
}

.fade-carousel .carousel-indicators>li {
  width: 15px;
  height: 15px;
  margin: 0 2px;
  background-color: rgba(0, 0, 0, 0);
  border-color: #fff;
  border-width: 3px;
}

.fade-carousel .carousel-indicators>li.active {
  background-color: #fff;
}


/********************************/


/*          Hero Headers        */


/********************************/

.hero {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  -webkit-transform: translate3d(-50%, -50%, 0);
  -moz-transform: translate3d(-50%, -50%, 0);
  -ms-transform: translate3d(-50%, -50%, 0);
  -o-transform: translate3d(-50%, -50%, 0);
  transform: translate3d(-50%, -50%, 0);
}

.hero h1 {
  font-size: 6em;
  font-weight: bold;
  margin: 0;
  padding: 0;
}

.fade-carousel .carousel-inner .item .hero {
  opacity: 0;
  -webkit-transition: 2s all ease-in-out .1s;
  -moz-transition: 2s all ease-in-out .1s;
  -ms-transition: 2s all ease-in-out .1s;
  -o-transition: 2s all ease-in-out .1s;
  transition: 2s all ease-in-out .1s;
}

.fade-carousel .carousel-inner .item.active .hero {
  opacity: 1;
  -webkit-transition: 2s all ease-in-out .1s;
  -moz-transition: 2s all ease-in-out .1s;
  -ms-transition: 2s all ease-in-out .1s;
  -o-transition: 2s all ease-in-out .1s;
  transition: 2s all ease-in-out .1s;
}


/********************************/


/*            Overlay           */


/********************************/

.overlay {
  position: absolute;
  width: 100%;
  z-index: 2;
  height: 1000px;
  background-image: url(../img/dotspattern.png);
  background-attachment: fixed;
}


/********************************/


/*          Custom Buttons      */


/********************************/

.btn.btn-lg {
  padding: 10px 40px;
}

.btn.btn-hero,
.btn.btn-hero:hover,
.btn.btn-hero:focus {
  color: #f5f5f5;
  background-color: #1abc9c;
  border-color: #1abc9c;
  outline: none;
  margin: 20px auto;
}


/********************************/


/*       Slides backgrounds     */


/********************************/

.fade-carousel .slides .slide-1,
.fade-carousel .slides .slide-2,
.fade-carousel .slides .slide-3 {
  height: 100vh;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.fade-carousel .slides .slide-1 {
  background-image: url(https://ununsplash.imgix.net/photo-1416339134316-0e91dc9ded92?q=75&fm=jpg&s=883a422e10fc4149893984019f63c818);
}

.fade-carousel .slides .slide-2 {
  background-image: url(https://ununsplash.imgix.net/photo-1416339684178-3a239570f315?q=75&fm=jpg&s=c39d9a3bf66d6566b9608a9f1f3765af);
}

.fade-carousel .slides .slide-3 {
  background-image: url(https://ununsplash.imgix.net/photo-1416339276121-ba1dfa199912?q=75&fm=jpg&s=9bf9f2ef5be5cb5eee5255e7765cb327);
}


/********************************/


/*          Media Queries       */


/********************************/

@media screen and (min-width: 980px) {
  .hero {
    width: 980px;
  }
}

@media screen and (max-width: 640px) {
  .hero h1 {
    font-size: 4em;
  }
}
<div class="container-fluid custom-fluid">
  <!-- Overlay -->
  <div class="overlay"></div>

  <div class="carousel fade-carousel slide" data-ride="carousel" data-interval="6000" id="bs-carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#bs-carousel" data-slide-to="0" class="active"></li>
      <li data-target="#bs-carousel" data-slide-to="1"></li>
      <li data-target="#bs-carousel" data-slide-to="2"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">
      <div class="item slides active">
        <div class="slide-1"></div>
        <div class="hero">
          <hgroup>
            <h1>We are creative</h1>
            <h3>Get start your next awesome project</h3>
          </hgroup>
          <button class="btn btn-hero btn-lg" role="button">See all features</button>
        </div>
      </div>
      <div class="item slides">
        <div class="slide-2"></div>
        <div class="hero">
          <hgroup>
            <h1>We are smart</h1>
            <h3>Get start your next awesome project</h3>
          </hgroup>
          <button class="btn btn-hero btn-lg" role="button">See all features</button>
        </div>
      </div>
      <div class="item slides">
        <div class="slide-3"></div>
        <div class="hero">
          <hgroup>
            <h1>We are amazing</h1>
            <h3>Get start your next awesome project</h3>
          </hgroup>
          <button class="btn btn-hero btn-lg" role="button">See all features</button>
        </div>
      </div>
    </div>
  </div>
</div>

我希望幻灯片中的文字显示在叠加模式上,但无法获取代码。提前谢谢!

2 个答案:

答案 0 :(得分:0)

设置object(或任何大于2的数字)以使其正常工作。

.hero { z-index: 5}
/********************************/
/*       Fade Bs-carousel       */
/********************************/
.fade-carousel {
    position: relative;
    height: 850px;
}
.fade-carousel .carousel-inner .item {
    height: 1000px;
}
.fade-carousel .carousel-indicators > li {
    width: 15px;
    height: 15px;
    margin: 0 2px;
    background-color: rgba(0,0,0,0);
    border-color: #fff;
    border-width: 3px;
}
.fade-carousel .carousel-indicators > li.active {
  background-color: #fff;
}

/********************************/
/*          Hero Headers        */
/********************************/
.hero {
    position: absolute;
    top: 50%;
    left: 50%;
    color: #fff;
    z-index: 5;

    text-align: center;
    text-transform: uppercase;
    -webkit-transform: translate3d(-50%,-50%,0);
    -moz-transform: translate3d(-50%,-50%,0);
    -ms-transform: translate3d(-50%,-50%,0);
    -o-transform: translate3d(-50%,-50%,0);
    transform: translate3d(-50%,-50%,0);
}

.hero h1 {
    font-size: 6em;    
    font-weight: bold;
    margin: 0;
    padding: 0;
}

.fade-carousel .carousel-inner .item .hero {
    opacity: 0;
    -webkit-transition: 2s all ease-in-out .1s;
       -moz-transition: 2s all ease-in-out .1s; 
        -ms-transition: 2s all ease-in-out .1s; 
         -o-transition: 2s all ease-in-out .1s; 
            transition: 2s all ease-in-out .1s; 
}
.fade-carousel .carousel-inner .item.active .hero {
    opacity: 1;
    -webkit-transition: 2s all ease-in-out .1s;
       -moz-transition: 2s all ease-in-out .1s; 
        -ms-transition: 2s all ease-in-out .1s; 
         -o-transition: 2s all ease-in-out .1s; 
            transition: 2s all ease-in-out .1s;    
}

/********************************/
/*            Overlay           */
/********************************/
.overlay {
  position: absolute;
    width: 100%;
    z-index: 2;
    height: 1000px;
    background-image: url(../img/dotspattern.png);
    background-color: rgba(250, 0, 0, .1);
    background-attachment: fixed;
}

/********************************/
/*          Custom Buttons      */
/********************************/
.btn.btn-lg {padding: 10px 40px;}
.btn.btn-hero,
.btn.btn-hero:hover,
.btn.btn-hero:focus {
    color: #f5f5f5;
    background-color: #1abc9c;
    border-color: #1abc9c;
    outline: none;
    margin: 20px auto;
}

/********************************/
/*       Slides backgrounds     */
/********************************/
.fade-carousel .slides .slide-1, 
.fade-carousel .slides .slide-2,
.fade-carousel .slides .slide-3 {
  height: 100vh;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.fade-carousel .slides .slide-1 {
  background-image: url(https://ununsplash.imgix.net/photo-1416339134316-0e91dc9ded92?q=75&fm=jpg&s=883a422e10fc4149893984019f63c818);
}
.fade-carousel .slides .slide-2 {
  background-image: url(https://ununsplash.imgix.net/photo-1416339684178-3a239570f315?q=75&fm=jpg&s=c39d9a3bf66d6566b9608a9f1f3765af);
}
.fade-carousel .slides .slide-3 {
  background-image: url(https://ununsplash.imgix.net/photo-1416339276121-ba1dfa199912?q=75&fm=jpg&s=9bf9f2ef5be5cb5eee5255e7765cb327);
}

/********************************/
/*          Media Queries       */
/********************************/
@media screen and (min-width: 980px){
    .hero { width: 980px; }    
}
@media screen and (max-width: 640px){
    .hero h1 { font-size: 4em; }    
}

答案 1 :(得分:0)

以下是我解决它的方法:

/********************************/
/*       Slides backgrounds     */
/********************************/
.fade-carousel .slides .slide-1, 
.fade-carousel .slides .slide-2,
.fade-carousel .slides .slide-3 {
  height: 100%;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  position: relative;
}

.fade-carousel .slides .slide-1:after, 
.fade-carousel .slides .slide-2:after,
.fade-carousel .slides .slide-3:after {
    content: '';
	display: block;
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	background: url(../img/dotspattern.png);
}

.fade-carousel .slides .slide-1 {
  background-image: url(../img/truck.jpg);
}
.fade-carousel .slides .slide-2 {
  background-image: url(https://ununsplash.imgix.net/photo-1416339684178-3a239570f315?q=75&fm=jpg&s=c39d9a3bf66d6566b9608a9f1f3765af);
}
.fade-carousel .slides .slide-3 {
  background-image: url(https://ununsplash.imgix.net/photo-1416339276121-ba1dfa199912?q=75&fm=jpg&s=9bf9f2ef5be5cb5eee5255e7765cb327);
}
<div class="container-fluid custom-fluid">
        <!-- Overlay -->
        <div class="overlay"></div>

        <div class="carousel fade-carousel slide" data-ride="carousel" data-interval="6000" id="bs-carousel">
            <!-- Indicators -->
            <ol class="carousel-indicators">
                <li data-target="#bs-carousel" data-slide-to="0" class="active"></li>
                <li data-target="#bs-carousel" data-slide-to="1"></li>
                <li data-target="#bs-carousel" data-slide-to="2"></li>
            </ol>

            <!-- Wrapper for slides -->
            <div class="carousel-inner">
                <div class="item slides active">
                    <div class="slide-1"></div>
                    <div class="hero">
                        <hgroup>
                            <h1>We are creative</h1>
                            <h3>При оценке дизайна и композиции читаемый текст мешает сосредоточиться. Lorem Ipsum используют потому, что тот обеспечивает более или стандартное</h3>
                        </hgroup>
                        <button class="btn btn-hero btn-lg" role="button">See all features</button>
                    </div>
                </div>
                <div class="item slides">
                    <div class="slide-2"></div>
                    <div class="hero">
                        <hgroup>
                            <h1>We are smart</h1>
                            <h3>Get start your next awesome project</h3>
                        </hgroup>
                        <button class="btn btn-hero btn-lg" role="button">See all features</button>
                    </div>
                </div>
                <div class="item slides">
                    <div class="slide-3"></div>
                    <div class="hero">
                        <hgroup>
                            <h1>We are amazing</h1>
                            <h3>Get start your next awesome project</h3>
                        </hgroup>
                        <button class="btn btn-hero btn-lg" role="button">See all features</button>
                    </div>
                </div>
            </div>
        </div>
    </div>