码迷,mamicode.com
首页 > Web开发 > 详细

CSS实例:图片导航块

时间:2017-10-20 11:57:10      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:des   type   文字   oct   新建   布局   content   历史   htm   


  1. 认识CSS的 盒子模型。
  2. CSS选择器的灵活使用。
  3. 实例:
    1. 图片文字用div等元素布局形成HTML文件。
    2. 新建相应CSS文件,并link到html文件中。
    3. CSS文件中定义样式
      1. div.img:border,margin,width,float
      2. div.img img:width,height
      3. div.desc:text-align,padding
      4. div.img:hover:border
      5. div.clearfloat:clear
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>img</title>
<link rel="stylesheet" type="text/css" href="../static/css/img.css">
</head>
<body>

<div class="recommend">
<div class="img">
<a href="http://www.gzcc.cn"><img src="http://www.gzcc.cn/2016/images/yhdh/01.jpg"></a>
<div class="desc"><a href="http://www.gzcc.cn">校园风光</a></div>
</div>
<div class="img">
<a href="http://www.gzcc.cn"><img src="http://www.gzcc.cn/2016/images/yhdh/02.jpg"></a>
<div class="desc"><a href="http://www.gzcc.cn">校园文化</a></div>
</div>
<div class="img">
<a href="http://www.gzcc.cn"><img src="http://www.gzcc.cn/2016/images/yhdh/06.jpg"></a>
<div class="desc"><a href="http://www.gzcc.cn">校园历史</a></div>
</div>
<div class="img">
<a href="http://www.gzcc.cn"><img src="http://www.gzcc.cn/2016/images/yhdh/07.jpg"></a>
<div class="desc"><a href="http://www.gzcc.cn">学生活动</a></div>
</div>
</div>

<div class="clearfloat">
<a href="http://www.gzcc.cn"><img src="http://www.gzcc.cn/2016/images/yhdh/04.jpg"></a><br>
<img src="http://www.gzcc.cn/2016/images/yhdh/01.jpg"><br>
<img src="http://www.gzcc.cn/2016/images/yhdh/02.jpg"><br>
<img src="http://www.gzcc.cn/2016/images/yhdh/06.jpg"><br>
<img src="http://www.gzcc.cn/2016/images/yhdh/07.jpg"><br>
</div>
</body>
</html>
img {
width: 300px;
}

div.img {
berder: 1px solid #ccc;
width: 200px;
float: left;
margin: 5px;
}

div.img img {
width: 100%;
height: auto;
}

div.desc {
text-align: center;
padding: 5px;
}

div.img:hover {
border: 1px solid #000000;
}

div clearfloat {
clear: both;
}

 技术分享

CSS实例:图片导航块

标签:des   type   文字   oct   新建   布局   content   历史   htm   

原文地址:http://www.cnblogs.com/yybx/p/7698041.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!