分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

CSS实例:图片导航块

发布时间:2023-09-06 01:19责任编辑:白小东关键词:CSS

1.认识CSS的 盒子模型。

2.CSS选择器的灵活使用。

3.实例:

   a.图片文字用div等元素布局形成HTML文件。

   b.新建相应CSS文件,并link到html文件中。

   c.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

HTML代码如下:

<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>广州商学院</title> ???<link rel="stylesheet"type="text/css"href="../static/css/202.css"></head><body > ????<div> ????????<div class="img"> ????????????<a href="http://www.gzcc.cn/html/xueyuanrongyu/"> ????????????????<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/html/banxuechengguo/"> ????????????????<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/html/xygk/ldgh/"> ????????????????<img src="http://www.gzcc.cn/2016/images/yhdh/03.jpg"> ????????????</a> ????????????<div class="desc"><a href="http://www.gzcc.cn">领导关怀</a></div> ????????</div> ????????<div class="img"> ????????????<a href="http://i.gzcc.cn/cas/login?service=http%3A%2F%2Fi.gzcc.cn%2Fdcp%2Findex.jsp"> ????????????????<img src="http://www.gzcc.cn/2016/images/yhdh/08.jpg"> ????????????</a> ????????????<div class="desc"><a href="http://www.gzcc.cn" >数字广商</a></div> ????????</div> ????????<div class="img"> ????????????<a href="http://www.gzcc.cn/html/xygk/xiaoyuanfengguang/"> ????????????????<img src="http://www.gzcc.cn/2016/images/yhdh/05.jpg"> ????????????</a> ????????????<div class="desc"><a href="http://www.gzcc.cn" >话说校园</a></div> ????????</div> ????????<div class="img"> ????????????<a href="http://www.gzcc.cn/html/shipinxiaoyuan/"> ????????????????<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/quanjingxiaoyuan/tour.html"> ????????????????<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 class="img"> ????????????<a href="http://www.gzcc.cn/html/xiaoyoufengcai/"> ????????????????<img src="http://www.gzcc.cn/2016/images/yhdh/04.jpg"> ????????????</a> ????????????<div class="desc"><a href="http://www.gzcc.cn" >校友风采</a></div> ????????</div> ????</div> ????<div class="clearfloat"> ????????<img src="http://www.gzcc.cn/2016/images/yhdh/01.jpg"> ????????<img src="http://www.gzcc.cn/2016/images/yhdh/02.jpg"> ????????<img src="http://www.gzcc.cn/2016/images/yhdh/03.jpg"> ????????<img src="http://www.gzcc.cn/2016/images/yhdh/08.jpg"><br> ????????<img src="http://www.gzcc.cn/2016/images/yhdh/05.jpg"> ????????<img src="http://www.gzcc.cn/2016/images/yhdh/06.jpg"> ????????<img src="http://www.gzcc.cn/2016/images/yhdh/07.jpg"> ????????<img src="http://www.gzcc.cn/2016/images/yhdh/04.jpg"> ????</div></body></html>

css代码如下:

 ???????img{ ???????????width: 300px; ???????} ??????div .img{ ???????????width: 130px; ???????????border: 1px solid #eeeeee; ???????????float: left; ???????????margin: 5px; ???????} ???????div.img img{ ???????????width: 100%; ???????????height: auto; ???????} ???????div.desc{ ???????????text-align: center; ???????????padding: 5px; ???????} ???????div.img:hover{ ???????????border: 1px solid #222222; ???????} ???????.clearfloat{ ???????????clear: both; ???????}

结果如下:

CSS实例:图片导航块

原文地址:http://www.cnblogs.com/jzx-089/p/7698770.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved