简体   繁体   English

如何使鼠标翻转点可点击?

[英]How to make a rollover div clickable?

I have a rollover with text div that I'd like to make clickable/linkable. 我有一个文本div滚动,我想使它可点击/可链接。 I'd like to whole div to be clickable not just the headings. 我希望整个div不仅可以单击标题。 But I'm unsure how to do so whether it's in my html or css or if I should add a script? 但是我不确定该怎么做,无论它是在我的html还是css中,还是应该添加一个脚本? Here's what I have: 这是我所拥有的:

<div class="box one">
        <a href="lost.html"><img src="http://www.mydogbreeders.com/wp-content/themes/dogBreedersResponsive2014/images/dogs/beagle.jpg" alt="Lost" data-over="images/placeholder-image-hover.png" data-out="images/placeholder-image-hover.png"></a>
        <div class="description">
        <div class="description-inner">
        <h3> heading </h3>
        <h4> subheading</h4>
        </div><!--description-inner-->
        </div><!--description-->
    </div> <!--box one-->



.box{
margin:0 20px 20px 0;
float: left;
position:relative;
}
.description {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background:#deefed;
color:#F00;
width:460px;
height:300px;
visibility:hidden;
opacity:0;
display:table;
}
.description-inner {
display:table-cell;
vertical-align:middle;
}
.description h3{
font-size:1.25em;
color:#00a8cf;
font-weight:bold;
font-style:italic;
text-transform:uppercase;
padding:20px 0 0 0;
margin:auto;
text-align:center;
width:90%;
top:50%;
border-top:1px #F00 solid;
}
.description h4 {
color:#00a8cf;
font-style:italic;
font-weight:normal;
padding:0 0 20px 0;
margin:auto;
text-align:center;
width:90%;
border-bottom:1px #F00 solid;
}
.box:hover .description {
visibility: visible;
opacity: 1;
}

And here's the demo: http://jsfiddle.net/L9bat8hj/ 这是演示: http : //jsfiddle.net/L9bat8hj/

Move end a-tag behind the rollover element. 将末端a-tag移动到滚动元素的后面。

<div class="box one">
    <a href="lost.html">
        <img src="http://www.mydogbreeders.com/wp-content/themes/dogBreedersResponsive2014/images/dogs/beagle.jpg" alt="Lost" data-over="images/placeholder-image-hover.png" data-out="images/placeholder-image-hover.png">
        <div class="description">
            <div class="description-inner">
                <h3> heading </h3>
                <h4> subheading</h4>
            </div><!--description-inner-->
        </div><!--description-->
    </a>
</div> <!--box one-->

http://jsfiddle.net/L9bat8hj/1/ http://jsfiddle.net/L9bat8hj/1/

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

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