我正在爲我的網站製作一個投資組合,並且正在使用砌體網格。但是,我試圖讓圖像在按順序打開時淡入。像這個網站上的東西Michael Molfetas。我試過使用CSS轉換,我檢查了砌體文檔,但我不能讓它工作。我把我在網上找到的股票圖像放在一起,但格式幾乎是我想要的。砌體網格圖像順序淡入
function myFunction() {
\t var x = document.getElementById("myTopnav");
\t if (x.className === "topnav") {
\t x.className += " responsive";
\t } else {
\t x.className = "topnav";
\t }
\t }
$(document).ready(function() {
$('#nav-icon3').on('click', function() {
$(this).toggleClass('open');
});
});
$('.grid').masonry({
// options
itemSelector: '.grid-item',
columnWidth: 250,
isFitWidth: true
});
* {
\t box-sizing: border-box;
}
html, body {
\t padding: 0;
\t margin: 0;
\t width: 100%;
\t height: 100%;
\t font-size: 1rem;
}
.header {
\t background-color: #FFF;
\t width: 100%;
\t margin: 0px auto;
\t display: block;
\t top: 0;
\t margin-top: 7%;
\t height: 80px;
}
h1 {
\t margin-left: 5%;
\t padding-left: 1%;
\t font-family: 'Lobster', cursive;
\t margin-top: 0;
\t float: left;
\t margin-bottom: 0;
\t color: #D18E8F;
}
#nav-icon {
\t width: 30px;
\t height: 30px;
display: block;
\t position: relative;
\t margin-right: 7%;
\t margin-top: 8px;
\t /*padding-right: 1%;*/
\t float: right;
\t -webkit-transform: rotate(0deg);
\t -moz-transform: rotate(0deg);
\t -o-transform: rotate(0deg);
\t transform: rotate(0deg);
\t -webkit-transition: .5s ease-in-out;
\t -moz-transition: .5s ease-in-out;
\t -o-transition: .5s ease-in-out;
\t cursor: pointer;
}
#nav-icon3 span {
\t display: block;
\t position: absolute;
\t height: 4px;
\t width: 100%;
\t background: #8c8c8c;
\t border-radius: 6px;
\t opacity: 1;
\t left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
#nav-icon3 span:nth-child(1) {
\t top: 0px;
}
#nav-icon3 span:nth-child(2), #nav-icon3 span:nth-child(3) {
\t top: 10px;
}
#nav-icon3 span:nth-child(4) {
\t top: 20px;
}
#nav-icon3.open span:nth-child(1) {
\t top: 10px;
\t width: 0%;
\t left: 50%;
}
#nav-icon3.open span:nth-child(2) {
\t -webkit-transform: rotate(45deg);
\t -moz-transform: rotate(45deg);
\t -o-transform: rotate(45deg);
\t transform: rotate(45deg);
}
#nav-icon3.open span:nth-child(3) {
\t -webkit-transform: rotate(-45deg);
\t -moz-transform: rotate(-45deg);
\t -o-transform: rotate(-45deg);
\t transform: rotate(-45deg);
}
#nav-icon3.open span:nth-child(4) {
\t top: 10px;
\t width: 0%;
\t left: 50%;
}
.topnav {
display: none;
}
.topnav.responsive {
\t display: block;
\t clear: both;
\t padding: 0;
\t height: 160px;
}
ul.topnav.responsive {
\t list-style: none;
\t font-family: 'Raleway', 'sans-serif';
\t float: left;
\t margin-left: 7%;
\t /*padding-left: 2%;*/
\t margin-top: 0;
\t width: 85%;
\t margin-bottom: 0;
}
ul.topnav.responsive li {
\t padding-top: 16px;
\t padding-bottom: 16px;
\t border-bottom: 1px solid #c6c6c6;
}
ul.topnav.responsive li a {
\t text-decoration: none;
\t color: #8c8c8c;
}
ul.topnav.responsive li a:hover {
\t color: #7EBEA3;
}
.grid {
overflow: hidden;
box-sizing: border-box;
margin: 0 auto !important;
}
.grid-item img {
width: 250px;
float: left;
padding: 0;
}
<!DOCTYPE html>
<html>
\t <head>
\t \t <meta charset="UTF-8">
\t \t <meta name="viewport" content="width=device-width, initial scale=1.0">
\t \t <title>Gabriella Farfan</title>
\t \t <link href="https://fonts.googleapis.com/css?family=Lobster|Raleway" rel="stylesheet">
\t \t <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
\t \t <link rel="stylesheet" href="http://fortawesome.github.io/Font-Awesome/assets/font-awesome/css/font-awesome.css">
\t \t <link rel="stylesheet" type="text/css" href="css/style.css">
\t \t <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
\t \t <script src="js/main.js"></script>
\t </head>
<body>
<div class="header">
\t \t <h1>Gabriella Farfan</h1>
\t \t \t <div id="nav-icon">
\t \t \t \t <div id="nav-icon3">
\t \t \t \t \t <a id="nav-icon3" onclick="myFunction();">
\t \t \t \t \t \t <span></span>
\t \t \t \t \t \t <span></span>
\t \t \t \t \t \t <span></span>
\t \t \t \t \t \t <span></span>
\t \t \t \t \t </a>
\t \t \t \t </div>
\t \t \t </div>
\t \t <ul class="topnav" id="myTopnav">
\t \t \t <li>
\t \t \t \t <a href="#">Work</a>
\t \t \t </li>
\t \t \t <li>
\t \t \t \t <a href="About.html">About Me</a>
\t \t \t </li>
\t \t \t <li style="border-bottom: none">
\t \t \t \t <a href="#">Contact</a>
\t \t \t </li>
\t \t </ul>
\t </div>
<div class="grid">
<div class="grid-item"><img src="https://www.istockphoto.com/resources/images/IllustrationsLanding/img_20912016.jpg"></div>
<div class="grid-item"><img src="https://previews.123rf.com/images/kotokomi/kotokomi1511/kotokomi151100206/48637357-Smiles-are-always-in-fashion-Inspirational-quote-handwritten-with-black-ink-and-brush-custom-letteri-Stock-Vector.jpg"></div>
<div class="grid-item"><img src="https://www.istockphoto.com/resources/images/IllustrationsLanding/img_52210298.jpg"></div>
<div class="grid-item"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRBlJjT5wpALRmHrOM3kLERHc01mw0GSDuMKheUGRCT2-rYN8_WfQ"></div>
<div class="grid-item"><img src="https://4.bp.blogspot.com/-dihnACz_au0/UJlZxIsDIWI/AAAAAAAAGPE/F4u3xcep2e4/s1600/stock-illustrations-on-etsy.jpg"></div>
<div class="grid-item"><img src="https://www.istockphoto.com/resources/images/IllustrationsLanding/img_88472599.jpg"></div>
<div class="grid-item"><img src="https://pbs.twimg.com/media/C9mly1dUwAAdTir.jpg"></div>
<div class="grid-item"><img src="http://www.elliedujour.com/wp-content/uploads/2017/03/2040070-1484093522-1.640x0c.jpg"></div>
<div class="grid-item"><img src="http://media.istockphoto.com/vectors/cute-cartoon-girl-vector-id528487686"></div>
</div>
</body>
</html>
謝謝你,我想你的答案幫助一點。我發現一個文章,做了我想要的加載效果,但包括一個按鈕來顯示圖像[鏈接](http://codepen.io/desandro/pen/yogHI)我想知道我可以做同樣的事情,但擺脫按鈕和onclick功能。我不擅長JavaScript。 – user7311741
對於圖像,您只需要類似的過渡效果,或向下滾動時加載圖像? – leusrox
這兩個都會很好,我有點設法在這裏做過渡效果https://codepen.io/GabriellaFarfan/pen/PmWWpm,但是當我調整窗口的大小時,所有圖像都浮到底部 – user7311741