简体   繁体   English

如何使盒子阴影可点击

[英]How to make box shadow clickable

I have an some text on screen that has a box shadow. 我在屏幕上有一些带有框阴影的文本。 The text is linking to an external website. 文本链接到外部网站。 However, I can only click the actual text to go to the external link. 但是,我只能单击实际文本以转到外部链接。 How do I make the box shadow clickable too so that I can also press anywhere on the texts box shadow and have the link still work. 如何使框阴影也可单击,以便我也可以在文本框阴影上的任意位置按一下,并使链接仍然有效。

It's Hard coded, so can not get perfect solution to this, but still you can try something like this. 它是硬编码的,因此无法获得完美的解决方案,但是您仍然可以尝试类似的方法。

 .outer { display:block; width:100px; padding: 2px 6px 6px 2px; /* The 6px is for right and bottom as they have more shadow 2px is for top and left*/ height:auto; cursor:pointer; } .inner { margin:0px; display:block; height:50px; width:100px; box-shadow:2px 2px 10px #333; } 
 <div class='outer'> <div class="inner"></div> </div> 

You can draw outer-box with bigger width and height. 您可以绘制具有更大宽度和高度的外箱。 and give them ancher tag. 并给他们ancher标签。

HTML HTML

<a href="http://google.com">
    <div class='outer-box'>
    <div class="box"></div>
    </div>
</a>

CSS CSS

 .outer-box{
        width:120px;
        height:120px;    
        display: inline-block;
    }.box{
        width:100px;
        height:100px;
        color:green;
        box-shadow: 10px 10px 5px #888888;
    }

As far as i know, It's not possible. 据我所知,这是不可能的。 Although you can make a div with a class of shadow and style it properly, and then make it clickable. 虽然您可以使div具有一类阴影并对其进行适当样式设置,然后使其可单击。

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

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