简体   繁体   English

将效果悬停在图片上作为链接提示

[英]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". 我试图获得一种效果,当悬停在图像上时,它会变得更暗(透明暗),并且在图像上方会出现文字“ View”。 I am using Bootstrap, so it needs to be responsive. 我正在使用Bootstrap,因此需要响应。

I tried to do categorieimg:a hover in CSS but it doesn't seems to respond. 我试图做categorieimg:a hover在CSS中categorieimg:a hover ,但似乎没有响应。 If it can be done with jQuery, all suggestions welcomed. 如果可以使用jQuery完成,则欢迎所有建议。

My HTML: 我的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. 为了实现您想要的功能,应该使用PNG图像而不是JPEF。 Because JPEG images will take the full space of the element and you can't show the background-color anywhere. 因为JPEG图像会占用元素的全部空间,所以您无法在任何地方显示背景色。

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=""> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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