【发布时间】:2014-02-18 06:16:02
【问题描述】:
我是使用 html/css 编程的新手,我正在尝试为我的班级编写一个网站。本质上,我正在尝试制作此页面的照片:www.stanford.edu/~tayoamos 变得更加透明,并在您将它们悬停时在顶部显示另一张图像。
这是我的 html 和 css:
HTML
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css"/>
<title> Instalert </title>
</head>
<body>
<div id="photos">
<img src="http://distilleryimage10.s3.amazonaws.com/cf16c8b4865411e3ab4012f602fa8bc2_8.jpg" alt ="JB1">
<img src ="http://distilleryimage7.s3.amazonaws.com/68042be2857511e382bb121b6297674b_8.jpg" alt="JB2">
<img src="http://distilleryimage10.s3.amazonaws.com/9a5b791283bb11e3b33312c4f3a07952_8.jpg" alt "JB3">
<img src="http://distilleryimage6.s3.amazonaws.com/230ce59a831a11e38fdc120c7c565106_8.jpg" alt "JB4">
<img src="http://distilleryimage9.s3.amazonaws.com/70d891a6853211e3828f1225728e27b1_8.jpg" alt ="KK1">
<img src="http://distilleryimage0.s3.amazonaws.com/4462c49a853011e385020e36ca40396c_8.jpg" alt "KK2">
<img src="http://distilleryimage10.s3.amazonaws.com/80531368852811e39c3c12a357c94c82_8.jpg" alt "KK3">
<img src="http://distilleryimage11.s3.amazonaws.com/97b2d28484bd11e3a7630e29514d93ff_8.jpg" alt "KK4">
<img src="http://distilleryimage5.s3.amazonaws.com/e66c6606856c11e399cf1225396dfdfd_8.jpg" alt "RR1">
<img src="http://distilleryimage3.s3.amazonaws.com/ceaedd12849211e3928a0e05f3709127_8.jpg" alt "RR2">
<img src="http://distilleryimage11.s3.amazonaws.com/37805c6e83e211e3a1ab0af82f025223_8.jpg" alt "RR3">
<img src="http://distilleryimage8.s3.amazonaws.com/dcda744c83d811e3bbfc122878962eb0_8.jpg" alt "RR4">
</div>
</body>
</html>
CSS
* { margin: 0; padding: 0; }
photos {
/* Prevent vertical gaps */
line-height: 0;
-webkit-column-count: 5;
-webkit-column-gap: 0px;
-moz-column-count: 5;
-moz-column-gap: 0px;
column-count: 5;
column-gap: 0px;
}
#photos img {
/* Just in case there are inline attributes */
width: 100% !important;
height: auto !important;
}
@media (max-width: 1200px) {
#photos {
-moz-column-count: 4;
-webkit-column-count: 4;
column-count: 4;
}
}
@media (max-width: 1000px) {
#photos {
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
}
@media (max-width: 800px) {
#photos {
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
}
}
@media (max-width: 400px) {
#photos {
-moz-column-count: 1;
-webkit-column-count: 1;
column-count: 1;
}
#photos img {
-webkit-transition: all 0,3s ease;
-moz-transition: all 0,3s ease;
-o-transition: all 0,3s ease;
-ms-transition: all 0,3s ease;
transition: all 0,3s ease;
}
#photos:hover {
opacity:.5;
}
}
}
非常感谢!!!
【问题讨论】:
-
如果你想显示另一个
img,你需要使用javascriptjQuery。 -
@user3240333 :用户参与通常是一个好兆头,说明答案是否有帮助! :)
-
有趣...在我取出 css 代码的第一部分后它就可以工作了。无论如何,再次感谢!
标签: html css image hover transparent