我想突出顯示一個帶有框的選定圖像,與「懸停」顯示的內容完全相同。有任何想法嗎?我嘗試了一些東西,但似乎沒有任何工作。懸停功能可以很好地工作,但點擊時,即使光標移開,我也需要一個框出現在保留的圖像周圍。下面粘貼了我的代碼。先謝謝你!!突出顯示所選圖像
<html><head>
<style type="text/css">
.event {
display: inline-block;
float: left;
}
.swatch {
width: 57px;
height: 45px;
display: inline-block;
float: left;
background-repeat: no-repeat;
padding: 5px;
background-position: center center;
margin-top: 8px;
}
.swatch:hover {
border: thin solid #999;
background-position: center center;
}
.selected {
border: thin solid #999;
}
.sq562-white {
background-image: url(../images/products/women/lifeguard_girlstee_white.jpg);
}
.sq562-red {
background-image: url(../images/products/women/lifeguard_girlstee_red.jpg);
}
</style>
<script type="text/javascript">
$(window).load(function(){
$(document).ready(function() {
// hide all the events
$("#bigCal p").hide();
$(".event a").click(function(evt) {
evt.preventDefault();
$("#bigCal p").hide();
var id = $(this).attr('id');
$("." + id).show();
});
});
});//]]>
</script>
</head>
<body>
<li class="event">
<a id="red" href="#" >
<div class="swatch sq562-white"></div>
</a>
</li>
<li class="event">
<a id="blue" href="#">
<div class="swatch sq562-red"></div>
</a>
</li>
</ul>
<div id="bigCal">
<p style="display: block; margin-top:25px; margin-bottom:-54px;" class="all blue"><a title="Red">Red</a></p>
<p style="display: none; margin-top:25px; margin-bottom:-54px;" class="all red"><a title="White">White</a></p>
</div>
</body></html>
這可以幫助:http://stackoverflow.com/questions/6491962/custom-checkbox/6492222#6492222 – kapa 2013-03-06 23:39:02