網頁設計好好玩(10502)
一、HTML
- 空白架構
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>20160626 瀑布流</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<h1>瀑布流</h1>
</body>
</html>
- 圖片顯示架構
<div class="container" >
<div class="row">
<div class="col-md-4">
<h2>Image00001</h2>
<img src="https://unsplash.it/500/333?image=1" alt="" class="img-responsive">
</div>
<div class="col-md-4">
<h2>Image00004</h2>
<img src="https://unsplash.it/500/500?image=2" alt="" class="img-responsive">
</div>
<div class="col-md-4">
<h2>Image00002</h2>
<img src="https://unsplash.it/500/333?image=3" alt="" class="img-responsive">
</div>
<div class="col-md-4">
<h2>Image00003</h2>
<img src="https://unsplash.it/500/333?image=4" alt="" class="img-responsive">
</div>
<div class="col-md-4">
<h2>Image00005</h2>
<img src="https://unsplash.it/500/333?image=5" alt="" class="img-responsive">
</div>
<div class="col-md-4">
<h2>Image00006</h2>
<img src="https://unsplash.it/500/333?image=6" alt="" class="img-responsive">
</div>
</div>
</div>
二、引入
-
<script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
三、調用插件
- 調用插件
<script>
$(function(){
$('.masonry').masonry({
itemSelector: '.item'
});
});
</script>
在 row 增加一個類別: masonry
在 col-md-4 增加一個類別 item
四、其他