简体   繁体   中英

Hover effect over image as a link ideas

I have an image on my page which I use as a link. I am trying to get an effect where when the hover is on the image it will become a little darker (transparent dark) and over the image will appear text saying "View". I am using Bootstrap, so it needs to be responsive.

I tried to do categorieimg:a hover in CSS but it doesn't seems to respond. If it can be done with jQuery, all suggestions welcomed.

My HTML:

@extends ('master') 

@section('content') 
<div class="row"> 
    <div class="col-md-12">
        <h1 class="text-center">Myhero Shop</h1> <br><br>
    </div> 
</div>  
<div class="row"> 

    @if ($categories)
    @foreach($categories as $category) 
    <div class="col-md-4 col-sm-6 text-center"> 
        <h3 >{{ $category['title'] }} </h3>   
        <p class><a href="{{ url('shop/'. $category['url']) }}" class="categorieimg"><img width="250" src="{{ asset('images/' . $category['image']) }}"></a></p>  
        <p>{!! $category['article']!!}</p>  

    </div> 
    @endforeach 
    @else 
    <div class="col-md-12"> <br><br>
        <p class="text-center" style="font-size: 18px"><b>No categories found...</b></p>
        <div 
            @endif
    </div>
    @endsection

To be able to achieve what you want, you should use PNG image not JPEF. Because JPEG images will take the full space of the element and you can't show the background-color anywhere.

See this working demo.

 img { width: 200px; height: 200px; background-color: red; } img:hover { background-color: gray; } 
 <img src="https://cdn4.iconfinder.com/data/icons/commerce-5/100/.svg-6-128.png" alt=""> 

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