link,hover,active三种按键状态,存放三张图片

缺点:

资源只有在被使用时,才会被加载。

页面第一次加载时,会出现短暂的延迟闪烁,造成一次不佳的用户体验。


图片整合技术 CSS-Sprite 雪碧图:

将三张图片整合为一张图片,在不同的伪类中通过设置 background-position 来切换图片。

一次请求一次加载,一次加载一张图片,相当于多张图片。

优势:

  • 减小资源的大小,省了颜色表
  • 提高了访问效率

实例效果:

html代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>湖南城市学院</title> <link rel="stylesheet" type="text/css" href="css/hncu.css" />
</head> <body>
<div id="hncu_header">
<div id="hncu_search">
<a href="#" id="search_btn"></a>
</div>
</div> <ul id="hncu_nav">
<li>
<a href="#">首页</a>
</li> <li>
<a href="#">新闻</a>
</li> <li>
<a href="#">联系</a>
</li> <li>
<a href="#">关于</a>
</li>
</ul> <div id="hncu_content">
<div id="hncu_left"></div>
<div id="hncu_center"></div>
<div id="hncu_right"></div>
</div> <div id="hncu_footer"> </div>
</body>
</html>

css源代码:

@charset "utf-8";

*{
margin: 0px;
padding: 0px;
} body{
background-color: #bfc;
} #hncu_header{
width: 1000px;
height: 200px;
background-color: skyblue; margin: 10px auto 10px;
} #hncu_search{
width: 360px;
height: 180px;
background-color: skyblue; overflow:hidden;
zoom:; margin: 10px auto 10px;
float: right;
} #search_btn {
display: block; width: 93px;
height: 29px;
background-color: skyblue;
background-repeat: no-repeat; position: relative;
left: 260px;
top: 144px;
}
#search_btn:link {
background-image: url(../img/btn.png);
} #search_btn:hover {
background-position: -93px 0px;
} #search_btn:active {
background-position: -186px 0px;
} #hncu_nav{
width: 1000px;
height: 70px;
background-color: blue; list-style:none;
margin:0px auto 10px; overflow:hidden;
zoom:;
} #hncu_nav li{
width: 25%;
height: 70px; float: left;
} #hncu_nav a{
width: 100%;
height: 70px;
color: white; line-height: 70px;
text-align: center;
text-decoration: none; float: left;
} #hncu_nav a:link{
background-color: blue;
} #hncu_nav a:visited{
background-color: blue;
} #hncu_nav a:hover{
background-color: red;
} #hncu_nav a:active{
color: blue;
} #hncu_content{
width: 1000px;
height: 600px;
background-color: yellow; margin:0px auto 10px;
} #hncu_left{
width: 200px;
height: 500px;
background-color: green; margin-top:50px;
float:left;
} #hncu_center{
width: 580px;
height: 500px;
background-color: #bfc; margin-top:50px;
margin-right: 10px;
margin-left: 10px;
float:left;
} #hncu_right{
width: 200px;
height: 500px;
background-color: pink; margin-top:50px;
float:left;
} #hncu_footer{
width:1000px;
height:200px;
background-color:skyblue; margin:0px auto 10px;
}

__x__(37)0909第五天__背景图按钮的更多相关文章

  1. __x__(36)0908第五天__背景 background

    1. 背景 background: red url(img/cat.gif) repeat-x fixed; 2. 背景颜色 background-color: red; 3. 背景图片 backgr ...

  2. __x__(38)0909第五天__雪碧图的制作

    1. 用ps打开目标图片若干. 2. 调整合适的画布大小. 3. 将图片拖曳到一张里. 4. 存储为Web所用格式,选择 png24 .

  3. __x__(39)0909第五天__ 表格 table

    表格 表示一种格式化的数据,如课程表,银行对账单... ... 在网页中,使用 table 创建一个表格. html代码: <!doctype html> <html> < ...

  4. __x__(40)0909第五天__表格 table 的 css 样式 美化

    如果就向下面的代码那样,不写 tbody , 则浏览器自添加 tbody , 并将所有的 tr 移入 tbody 意味着 tr 并非 table 的子元素,而是 tbody 的子元素. 所以 以后编写 ...

  5. __x__(41)0909第五天__长表格

    长表格 银行流水,表格很长... 则需要将表格分为 表头 thead ,主体数据 tbody , 表格底部 tfoot 三个标签无顺序要求,易于维护:thead → tfoot → tbody 如果没 ...

  6. __x__(29)0908第五天__高度塌陷 问题

    高度塌陷 在文档流中,父元素的高度默认是被子元素撑开的. 但是当为 子元素 设置 float 时,子元素会完全脱离文档流,无法再撑开父元素,导致父元素高度塌陷...以致于布局混乱 变成 BFC块级格式 ...

  7. __x__(30)0908第五天__导航条的练习 <div>版本

    效果图:  html源代码: <!doctype html> <html> <head> <meta charset="utf-8" /& ...

  8. __x__(31)0908第五天__导航条的练习 <ul> 版本

    效果图:  html代码: <!doctype html> <html> <head> <meta charset="utf-8" /&g ...

  9. __x__(34)0908第五天__ 定位 position

    position 定位 指将原始摆放到页面的任意位置. 继承性:no 默认值:static        没有定位,原始出现在正常的文档流中 可选值: static :    默认值,元素没有开启定位 ...

随机推荐

  1. vue动态添加对象属性,视图不渲染

    发现数据确实改变了.但是视图没有渲染.原因是赋值的问题,应该这样动态增加属性 vm.$set(vm.template.titleAttachInfoDetail,newKey,newVal) vm 当 ...

  2. tomcat无法正常关闭问题分析及解决

    问题描述 通常,我们都会直接使用tomcat提供的脚本执行关闭操作,如下: # sh bin/shutdown.sh Using CATALINA_BASE: /usr/local/apache-to ...

  3. python学习04

    数据类型-list,tuple 1) 1.1.list的表现方法:[1,2,3,4,5,6] 1.2.计算list的长度用 len() 1.3 list中的索引 a =[1,2,3,4,5] a[1] ...

  4. windows的git的安装和配置

    下载并安装git(安装过程中采用默认选项) 进入gitbash(gitbash集成了windows和linux的命令) 使用git --version查看是否安装成功: 用vim .gitconfig ...

  5. react简书

    开发项目之前的准备 https://www.chromefor.com/  登录此网站 下载相关crx react插件 不然要FQ 下载 React Developer Tools 谷歌插件下载 Re ...

  6. python 三大框架之一Django入门

    Django 是从真实世界的应用中成长起来的,它是由 堪萨斯(Kansas)州 Lawrence 城中的一个 网络开发小组编写的. 它诞生于 2003 年秋天,那时 Lawrence Journal- ...

  7. WebService - [Debug] javax.xml.ws.WebServiceException: Undefined port type

    背景: 使用JDK来开发java web service (Create a SOAP-based RPC style web service endpoint by using JAX-WS). 具 ...

  8. (转)Java代码书写规范

    0. 安装阿里代码规范的eclipse插件 https://www.cnblogs.com/caer/p/7753522.html 1.基本原则 强制性原则:     1.字符串的拼加操作,必须使用S ...

  9. CSP应用开发-CryptAPI函数库介绍

    基本加密函数为开发加密应用程序提供了足够灵活的空间.所有CSP的通讯都是通过这些函数.一个CSP是实现所有加密操作的独立模块.在每一个应用程序中至少需要提供一个CSP来完成所需的加密操作.如果使用多于 ...

  10. C语言经典题目

    回顾一下吧: 一. 有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 解析:可填在百位.十位.个位的数字都是1.2.3.4.组成所有的排列后再去 掉不满足条件的排列. 常规 ...