0
Gentlemen, I’m pulling some images from the database, and when the user hovers over them an opaque red color will be above them, and a title and text will be shown.
I did this by putting the image in a div, and inside this div I put another div with these 2 contents. I’m trying to make her invisible and put the Hover mouse effect on her, but I could only do with position:absolute
and the z-index
, but that way, as soon as 4 images appear and a fifth is loaded - that should go to the next line - it sits on top of the first.
I want to leave her like this - see example How are you getting - view image
HTML
<div class="pure-g">
@foreach($eventos as $eventos)
<div class="pure-u-6-24">
<a href="">
<div class="conteudoEventoEscondido hideEvento">
<p class="tituloEventoEscondido">{{$eventos->nome}}</p>
<p class="localEventoEscondido">{{$eventos->local}}</p>
</div>
<img src="assets/images/eventos/thumbs/{{$eventos->miniatura}}" alt="{{$eventos->nome}}">
</a>
</div>
@endforeach
</div>
CSS
.pure-u-6-24 {
.marginReduzida(6px,0px);
a{
text-decoration: none;
&:hover {
.conteudoEventoEscondido {
display: block !important;
}
}
.conteudoEventoEscondido {
width: 17.25%;
height: 36.5%;
display: block;
background-color: rgba(210, 183, 134, 0.8);
background: rgba(210, 183, 134, 0.8);
color: rgba(210, 183, 134, 0.8);
.padding(30px,0,0,30px);
.tituloEventoEscondido {
font-size: 16px;
font-weight: bold;
.colorFonte(#4B392C);
.margin(0,0,8px,0);
}
.localEventoEscondido {
font-size: 12px;
font-style: italic;
.colorFonte(#4B392C);
}
z-index: 2;
position: absolute;
}
img {
@media screen and (min-width: 320px) and (max-width: 768px){
width: 100%;
}
z-index: 1;
position: absolute;
}
}
}
But in this case I am working with responsive layout, Absolute would screw with everything x.x.
– Allan Ramos
@Allan Not necessarily - I myself use this type of solution in responsive layouts.
absolute
always works together with the definitionrelative
of a parent object in its hierarchy. In this case, theDIV
is the wrapper.– OnoSendai
I may be mistaken, but H2 would be absolutely positioned in a relatively positioned element (IMG). And in this case, as long as you deal with the responsiveness of the image, the caption wouldn’t get in the way of anything.
– Bruno Augusto
@Onosendai Placing the
position:relative
in the wrapper the mouse Hover does not even work x.x.– Allan Ramos
@Conflict with some previous definition, perhaps?
– OnoSendai