我的页面上有一个基于 CSS 的悬停/点击效果,效果很好。当项目 (.print) 悬停时,全彩图像 (.print_photo) 会出现在右侧。单击该项目时,图像将变为灰色并出现一个文本框 (.print_text)。
单击功能仅在您按住单击时才起作用,我希望它在单击后保持可见,直到单击另一个项目。这可能吗?
(我没有足够的声誉来发布图像,一旦我发布我会发布它)图像大小是宽度:620px;高度:490px;
CSS
#bgtextbox{
width:320px;
height:391px;
background-color:#BCBEC0;
margin:130px 0 0 0px;
position:absolute;
text-align:center;
font-family:Arial, Helvetica, sans-serif;
z-index:1;
}
/* hover/click START */
.print{
width:340px;
height:40px;
background-color:#E6E7E8;
margin:6px 0 0 0px;
position:relative;
text-align:center;
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
line-height:40px;
border:1px solid #E6E7E8;
z-index:12;
}
.print_photo{
width:620px;
height:490px;
margin:-48px 0 0 370px;
text-align:center;
background-repeat:no-repeat;
position:absolute;
z-index:2;
}
.print_photo img{
opacity:0;
max-height:100%;
max-width:100%;
}
.print_text{
width:430px;
height:150px;
margin:292px 0 0 397px;
position:absolute;
border-radius: 20px / 20px;
opacity:.75;
color:transparent;
z-index:13;
}
.print:hover{
border:1px solid #F15A24;
cursor:pointer;
}
.print:hover ~ .print_photo img{
opacity:1;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
.print:active ~ .print_photo img{
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
opacity:.5;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
.print:active ~ .print_text{
background-color:#000;
color:#FFF;
}
/* END */
HTML
<div id="bgtextbox">
<div class="print">PRINT</div>
<div class="print_photo"><img src="images/print.png"</div></div>
<div class="print_text">PRINT TEXT GOES HERE</div>
</div>