Overflow:hidden
不適合我。灰色框仍留在圖片下方。我不知道它有什麼問題。我使用了youtube教程中的這段代碼。 如果有人能幫助我,我會非常感激。爲什麼溢出:隱藏不起作用?
.main
{
border: 10px solid white;
width:378;
height:250;
margin:50px auto;
box-shadow:0px 0px 25px black;
overflow:hidden;
}
.main:hover img
{
-webkit-transform:scale(2,2) rotate(45deg);
}
.main:hover .content
{
-webkit-transform:translate(-383px);
}
img
{
-webkit-transition: -webkit-transform: 300ms; \t
}
.content
{
\t width:378;
\t height:250;
\t background: rgba(118,115,115,0.5);
-webkit-transition: -webkit-transform: 300ms;
}
button
{
\t width:100%;
\t height:50px;
\t margin-top:200px;
\t background:black;
\t border:0;
\t cursor:pointer;
\t color:white;
\t font:16px tahoma;
}
button:hover {
\t opacity: 0.5;
}
<div class="main"><img src="img/switch.jpg" height="250" width="378"><div class="content"><button>Pepe Kalvier Switches</button></div></div>
你應該在'px'或'%'中給'height'和'width',而不是'height:232',它應該像'height:232px;' –
感謝bro,我不知道我是如何忽略px的。 –