在下面的小提琴中,我在此结构中具有带有href和背景图片的锚标记,该文本使href停止可单击以使用相同的HTML结构解决该问题的任何想法?
<div class="banner-container">
<div class="banner-box">
<div class="banner-div">
<div class="bannerheading">
<p><span>The correct link should be </span></p>
</div>
</div>
<a href="https://www.google.com/">
<div class="banner-img" style="background-image:url('https://ssl.gstatic.com/gb/images/i1_1967ca6a.png');">
</div>
</a>
</div>
请检查框中的红色边框是否不可点击https://jsfiddle.net/uqbhcdn6/1/。
任何想法将不胜感激:)
答案 0 :(得分:1)
将pointer-events:none;
属性添加到.banner-div
类中。
答案 1 :(得分:0)
一种可能性是给.bannerheading
赋予样式pointer-events: none;
,尽管这样将无法选择.bannerheading
中的文本:
.banner-container {
min-height: 300px;
position: relative;
margin-bottom: 20px;
}
.banner-container .banner-box {
border-radius: 12px;
min-height: 350px;
background-color: #1C2841;
overflow: hidden;
}
.banner-container .banner-box .banner-div {
top: 50%;
height: auto;
-ms-transform: translateY(-50%);
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
padding: 20px;
z-index: 3;
border-radius: 12px;
border:1px solid red;
}
.banner-div {
position: absolute;
width: 100%;
height: 100%;
z-index: 999;
top: 34%;
padding: 10px;
pointer-events: none;
}
.banner-container .banner-box .banner-div .bannerheading {
color: #fff;
}
banner-container .banner-box .banner-img {
min-height: 350px;
border-radius: 12px;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
-webkit-transform: scale(1);
-ms-transform: scale(1);
-moz-transform: scale(1);
transform: scale(1);
}
.banner-img {
height: 100%;
width: 100%;
min-height: 300px;
background-size: cover;
background-position: center;
}
<div class="banner-container">
<div class="banner-box">
<div class="banner-div">
<div class="bannerheading">
<p><span>The correct link should be </span></p>
</div>
</div>
<a href="https://www.google.com/">
<div class="banner-img" style="background-image:url('https://ssl.gstatic.com/gb/images/i1_1967ca6a.png');">
</div>
</a>
</div>
</div>