How to leave a div and an image over a Carousel?

Asked

Viewed 6,280 times

2

I want to run a paddle and over it, a div and the logo, to give that effect of being superimposed.

Try to do like this EXAMPLE, but without success. When I add such properties (absolute e relative) the Carousel code does not work.

O que desejo fazer

The Carousel-shaped slide background images. The green div and logo superimposed on the Carousel.

I tried something like:

#myCarousel{
 position: absolute;
}

#fixa{
 position: absolute;
 width: 20%;
 height: 400px;
 background: black;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>

<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
  </ol>

  
  <div class="carousel-inner" role="listbox">
    
    <div id="fixa">
 		DIV QUE SERÁ SOBREPOSTA
   	</div>
    
    <div class="item active">
      <img src="http://s3.amazonaws.savoir.com.br/cea.com.br/imagem/cadastrocqlv/imagem/cadastrocqlv-53440.jpg">
    </div>

    <div class="item">
      <img src="http://www.asia-turismo.com/imagens/asia-imagem.jpg">
    </div>
  </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

How can I do that?

2 answers

1

To overwrite files use the css property z-index:9999 where 9999 is the value Voce wants, the higher up it will be.

  • Giving a research, I learned that put the z-index:999 is a bad practice because this is not a conscious form of positioning.

  • I was not aware of this, but cool ball show, the number 9999 was to have a base even not to use exactly this.

1


See if this is what you wanted:

#fixa{
  height: 100%;
  width: 50%;
  background: rgba(15, 215, 115, 0.5);
  z-index: 10;
  position: absolute;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
  </ol>
  <div class="carousel-inner" role="listbox">
    
    <div id="fixa">
 		  
   	</div>
    
    <div class="item active">
      <img src="http://s3.amazonaws.savoir.com.br/cea.com.br/imagem/cadastrocqlv/imagem/cadastrocqlv-53440.jpg">
    </div>

    <div class="item">
      <img src="http://www.asia-turismo.com/imagens/asia-imagem.jpg">
    </div>
  </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

To his div#fixa assigns a height: 100%, and continued with the position: relative, and used the z-index: 10, as the other elements did not have in their specifications the property z-index, what you have will be what will be above all. It should be noted that the div do not override the controllers.

The transparency was with the rgba(15, 215, 115, 0.5), where the last parameter is the opacide that goes from 0 to 1. This could be replaced by rgb(15, 215, 115) and a opacity: 0.5.

  • That’s exactly it, thank you! I had completely forgotten the property z-index rsrs And if I want to put any other image and or div on top (being more specific, the LOGO), again just browse by z-indexand ready?

  • 1

    @Zkk. Yes, that’s basically it. Remembering that it will depend a little on position, but in the case putting a absolute, I imagine everything will go well :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.