javascript - 如何使翻转 div 可点击?

标签 javascript css

我有一个带有文本 div 的鼠标悬停,我想将其设置为可点击/可链接。我希望整个 div 都可以点击,而不仅仅是标题。但我不确定该怎么做,无论是在我的 html 还是 css 中,还是我应该添加脚本?这是我拥有的:

<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;
}

这是演示:http://jsfiddle.net/L9bat8hj/

最佳答案

将结束 a 标签移到滚动元素后面。

<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/

关于javascript - 如何使翻转 div 可点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27763708/

相关文章:

javascript - 使用 HTML、CSS 和 960.gs 的灵活全 Angular 背景

javascript - 如何在webkit中获取多列布局中的列数

javascript - 重置类中所有图像的大小

html - 为什么我的列表样式图像在不同浏览器中的位置不同

jQuery 多状态切换

javascript - 获取网页中arduino数字引脚的状态

javascript - D3 v4 - 尝试将我的数据文件 '2017-09-19T00:00:00' 中这样格式化的日期转换为更易读的 'Sep 19, 2017'

javascript - 使用 JQuery 拆分变量

html - 为什么 .css 文件没有改变字体系列?

javascript - YouTube iframe API-隐藏HUD