假设图片区域的大小固定为250×300px,那么咱们能够写出以下的样式css
.picture-area { width: 250px; height: 300px; margin: 1em; }
固然简单以下的html是不能限制图片大小的html
<div class=“picture-area”> <img src=“…” alt=“…”> </div>
换个思路,将图片做为div的背景图片git
<div style=“background-image: url(‘…’)”></div>
此时须要将该div铺满picture-area,所以定义样式github
.picture { position: absolute; left:0; right:0; top:0; bottom:0; background-repeat: no-repeat; background-position: center; background-size: cover; }
因而获得限制图片大小的div以下web
<div class=“picture-area”> <div class=“picture” style=“background-image: url(‘…’)”></div> </div>
因为picture使用了绝对定位,根据w3school上的解释:“生成绝对定位的元素,相对于 static 定位之外的第一个父元素进行定位”,若是元素没有定义position,默认position为static,所以将父元素picture-area的定位方式设为position:relative便可。bootstrap
1 .picture-area { 2 3 width: 250px; 4 5 height: 300px; 6 7 margin: 1em auto 1em auto; 8 9 position: relative; 10 11 } 12 13 14 15 16 .picture-area .picture { 17 18 position: absolute; 19 20 left: 0; 21 22 top: 0; 23 24 right: 0; 25 26 bottom: 0; 27 28 background-repeat: no-repeat; 29 30 background-position: center 36%; 31 32 background-size: cover; 33 34 }
Github的每一个repository有Github Pages,可使用Github Pages作静态页面演示。ide
所以首先在Github上建立一个名为VacationSchedule的repository。url
(1) clone项目到本地spa
git clone https://github.com/zrss/VacationSchedule.git
(2) 进入项目文件夹code
cd VacationSchedule
(3) 切换到gh-pages分支,这个分支的文件才被视为Github Pages的文件
git checkout --orphan gh-pages
(4) 在项目文件夹下写web代码便可。目录结构例如:
/VacationSchedule /bootstrap /css /images index.html
(5) 提交代码
git commit -a
(6) merge到gh-pages
git push
便可经过http://zrss.github.io/VacationSchedule/查看到web页面效果;通常来讲,Github Pages能够经过http://<user_name>.github.io/<repository_name>/来访问。
样式参考:http://xiumi.us
GitHub Pages参考:http://www.ruanyifeng.com/blog/2012/08/blogging_with_jekyll.html