1
我正在學習CSS的過程。幫助需要CSS懸停圖像
我想在用戶將鼠標懸停在畫廊中時在屏幕中間顯示圖像。
但是,圖像懸停在圖像本身。 這是我的代碼。
body {
margin: 0;
padding: 0;
background: #EEE;
font: 10px/13px 'Lucida Sans',sans-serif;
}
.wrap {
overflow: hidden;
margin: 50px;
}
.box {
float: left;
position: relative;
width: 25%;
padding-bottom: 25%;
color: #FFF;
}
.boxInner {
position: absolute;
left: 30px;
right: 30px;
top: 30px;
bottom: 30px;
overflow: hidden;
background: #66F;
}
.boxInner img {
width: 100%;
}
.thumbnail:hover img{
border: 1px solid transparent;
}
.thumbnail span{
position: absolute;
padding: 5px;
left: -1000px;
visibility: hidden;
color: black;
text-decoration: none;
}
.thumbnail span img{
border-width: 0;
width:70%;
height: auto;
padding: 2px;
}
.thumbnail:hover span{
visibility: visible;
top: 0;
left: 230px;
z-index: 50;
}
用這種方法,爲什麼圖像消失,當鼠標移到?可以使框中的圖像保持並將圖像懸停在中間? – newbieprogrammer 2014-09-24 08:43:18
如果是這種情況,你必須使用2個圖像,因爲該框是固定大小的圖像無法離開它 – himanshu 2014-09-24 08:45:12