我们使用这个css
.event_box > a img{
width: 100%;
filter: brightness(70%);
display: block;
-webkit-transition: all 0.7s linear;
-moz-transition: all 0.7s linear;
-ms-transition: all 0.7s linear;
-o-transition: all 0.7s linear;
transition: all 0.7s linear;
}
.event_box >a:hover img:hover{
filter:brightness(100%)
}
.event_box .text-picture
{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
color: #fff;
height: 0;
text-align: center;
font-family: Open Sans Semibold;
font-size: 26px;
font-weight: bold;
color: #fff;
text-transform: uppercase;
z-index: 999;
}
与此html结合使用:
<div class="row">
<div class="event_box">
<a href="'.$templink.$langlink.$paginalink.'portfolio'.$caselink.'1000-wishes">
<img src="'.$url.'images/home/1000-wishes.jpg" alt="1000 Wishes"/>
<div class="text-picture">
1000 Wishes
</div>
</a>
</div>
</div>
您将在图片上看到带有文字的图片。 鼠标悬停效果一直有效,直到你的鼠标指针击中文本,鼠标悬停效果停止。 这个问题有解决方法吗?
.event_box > a img{
width: 100%;
filter: brightness(70%);
display: block;
-webkit-transition: all 0.7s linear;
-moz-transition: all 0.7s linear;
-ms-transition: all 0.7s linear;
-o-transition: all 0.7s linear;
transition: all 0.7s linear;
}
.event_box >a:hover img:hover{
filter:brightness(100%)
}
.event_box .text-picture
{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
color: #fff;
height: 0;
text-align: center;
font-family: Open Sans Semibold;
font-size: 26px;
font-weight: bold;
color: #fff;
text-transform: uppercase;
z-index: 999;
}
<div class="row">
<div class="event_box">
<a href="http://www.jcsl.nl/clean/images/home/1000-wishes.jpg">
<img src="http://www.jcsl.nl/clean/images/home/1000-wishes.jpg" alt="1000 Wishes">
<div class="text-picture">
1000 Wishes
</div>
</a>
</div>
</div>
答案 0 :(得分:2)
不确定。将.text-picture
添加到.event_box > a img{
width: 100%;
filter: brightness(70%);
display: block;
-webkit-transition: all 0.7s linear;
-moz-transition: all 0.7s linear;
-ms-transition: all 0.7s linear;
-o-transition: all 0.7s linear;
transition: all 0.7s linear;
}
.event_box >a:hover img:hover{
filter:brightness(100%)
}
.event_box .text-picture
{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
color: #fff;
height: 0;
text-align: center;
font-family: Open Sans Semibold;
font-size: 26px;
font-weight: bold;
color: #fff;
text-transform: uppercase;
z-index: 999;
pointer-events: none;
}
CSS。
这样做是让鼠标事件(如悬停,点击等)通过元素。通过这样做,图像的“悬停”状态不会被中断,因此它将保持明亮。
<div class="row">
<div class="event_box">
<a href="http://www.jcsl.nl/clean/images/home/1000-wishes.jpg">
<img src="http://www.jcsl.nl/clean/images/home/1000-wishes.jpg" alt="1000 Wishes">
<div class="text-picture">
1000 Wishes
</div>
</a>
</div>
</div>
{{1}}
答案 1 :(得分:2)
将指针事件无添加到文本图片类
.event_box .text-picture
{
//this line
pointer-events:none;
----
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
color: #fff;
height: 0;
text-align: center;
font-family: Open Sans Semibold;
font-size: 26px;
font-weight: bold;
color: #fff;
text-transform: uppercase;
z-index: 0;
}