简体   繁体   中英

Angular header to overlap my bootstrap carousel

I currently have a header with a bootstrap carousel under the header. I want to make it so the header sits on top of the carousel so that when I make the header transparent it shows the images of the carousel through my header. Any input on this would be greatly appreciated and I have provided the code below.

app.component.html

<ng-container>
  <app-header></app-header>
  <app-carousel></app-carousel>
  <app-product-carousel></app-product-carousel>
  <app-promo></app-promo>
  <app-footer></app-footer>
</ng-container>

carousel.component.html

<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
  <div class="carousel-indicators">
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
    <button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
  </div>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="assets/rolex2.jpg" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="assets/rolex3.jpg" class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="assets/rolex.jpg" class="d-block w-100" alt="...">
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div>

header.component.html

<div class="myHeader">
<h1>NEBULA</h1>
  <app-navbar></app-navbar>
</div>

header.componet.css

.myHeader {
  padding: 20px;
  text-align: center;
  background: transparent;
  color: white;
  font-size: 30px;
  transition: top 0.3s;
  width: 100%;
  overflow: hidden;
  font-family: 'Cormorant Garamond', serif;
}

.myHeader:hover {
  background: #1b1b1b;
}

h1 {
  letter-spacing: 5px;
  margin-top: -6PX;
}

I found out what I was doing wrong. By adding a absolute position and a z-index of 1 to my header it resolved this issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM