H5 Mosh教程笔记
先列出教程中会用到的网站
网站H5规范验证网站
CSS格式规范验证网站
转义字符查询
免费图片下载网站
免费图片视频下载网站
浏览器HTML标签,CSS属性支持情况查询网站
CSS一致化工具安装
渐变色代码生成网站
CSS形状代码生成网站
字体网站fontsquirrel
字体网站fonts
字体网站myfonts
rem字体大小预览网站
css雪碧图工具网站,或者谷歌一下css sprites
DataURI生成网站,或者谷歌一下Data URI Generator
CSS滤镜展示
图片裁切工具网站,或者谷歌一下CSS Clip Generator
不同分辨率图片生成网站
图片格式转换网站
矢量图背景网站
图标字体网站
教程开始
· 图片
· 内容图片
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.meal {
/* 全屏展示图片,不需要提供高度,浏览器会自动计算高度 */
width: 100vw;
}
</style>
</head>
<body>
<!-- meal.jpg是位图,放大之后,像素不够描绘那么多细节,就会模糊 -->
<img class="meal" src="images/meal.jpg" alt="">
</body>
</html>
· 背景图片
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
background: url(images/bg-sanfrancisco.jpg);
/* 图片尺寸不够大时,不重复展示图片来布满整个屏幕 */
/* 如果想在横轴或纵轴方向重复图片 */
/* 可以设置repeat-x或者repeat-y */
background-repeat: no-repeat;
/* 确定背景图位置,参数表示x轴位置和y轴位置 */
/* 或者使用百分比表示(相对于X轴或Y轴的长度百分比) */
/* background-position: 100px 100px; */
/* 修改背景图大小,宽,高,也可以使用百分比 */
background-size: 100px 100px;
/* 此时高度用100%,会导致图片消失,因为默认高度时0,0的100%,还是0 */
/* 需要手动指定页面高度 */
background-size: 100% 100%;
height: 300vh;
/* 将图片拉伸并覆盖整个容器 */
background-size: cover;
/* 在页面滚动时,背景图不动,只是页面内容动 */
/* 同时,因为图片不会动,所以,即使时cover效果,也只会把图片拉满一整屏,而不是高度设置的3倍屏幕高度 */
background-attachment: fixed;
}
</style>
</head>
<body>
<h1>My Heading</h1>
</body>
</html>
· 雪碧图
雪碧图就是把多张用到的图合并成一张图,在下载的时候能减少文件大小,通过CSS来切分图片,在生成雪碧图的时候,雪碧图生成工具会同时生成图片和对应的CSS(代码中bg开头的样式),直接拷贝使用就好
css雪碧图工具网站,或者谷歌一下css sprites
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.bg-landing {
width: 100px;
height: 100px;
background: url("images/css_sprites.png") -10px -10px;
display: inline-block;
}
.bg-rocketship {
width: 100px;
height: 100px;
background: url("images/css_sprites.png") -130px -10px;
display: inline-block;
}
.bg-saturn {
width: 100px;
height: 100px;
background: url("images/css_sprites.png") -10px -130px;
display: inline-block;
}
.bg-ufo {
width: 100px;
height: 100px;
background: url("images/css_sprites.png") -130px -130px;
display: inline-block;
}
.bg-dishes {
width: 100px;
height: 100px;
background: url("images/css_sprites.png") -250px -10px;
display: inline-block;
}
</style>
</head>
<body>
<span class="bg-dishes"></span>
<span class="bg-landing"></span>
<span class="bg-rocketship"></span>
<span class="bg-saturn"></span>
<span class="bg-ufo"></span>
</body>
</html>
· 数据标识符 Data URLs
数据标识符就是把文件内容写到URL里,就不用下载文件,而是直接把文件内容嵌入到HTML里。Data URL的标识是data
开头。数据标识符的方式会比源文件要大,而且不好维护,尽量少用
DataURI生成网站,或者谷歌一下Data URI Generator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIW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7MNuo4SouvpZ0RPC1oyTbIuacj0yiQxiNiQ9bxp9bgcn5E5ibJNVplrTKLMPtVfyG829N+VsybbJLz2eq+X2pgaXfzrmPvKHLqvtTn/Q0p+WZSgoHSUjgxaUpOpMo20JJFehSDmIhayXtTG0+r4tGy7IuaiDLS1zKqU2We74eifd1j/ZqxXLWOkK0R4PfReb42cGtuz74rjs++i/TpZvjGn9nUqxolESxKZXp0gBhFzcq1N57XpjBzPynaFGETZIkek6Gb/Jgzf3s3m/1tJU7UrS6ME1eum90ZpyapS8vssl98Xp976oP29r87D/d8p4wNesUIUEYVMcinbnjae0aazcrokc09EJ8qmzIY4G8PGP4hnln837ux/POe9zJRZkd4IvTeFZD5/1OHBt8r2rdHP36/5pblefzXlF5Dv8BJJdJROZJGSupZtX9ZD2S7K8ZysO1rb8byIuSgnzkiPRQwfCe37WubHlHJodUitZBDhjdR7UwhqJdNVpfu4lh/Ht8sQ8sEs8cWaD8n2fsqd6ngs697RnJYb6m5p045s+6mtVuryioiVMpwv5S0PSz8emT+WpXzMVMboGnlIrslKh/Cm0PPPvWiBBeEF4aV6r8I7XBU+p7ix8DnhRY8Gj+K73UDnlRvcWOfGBq+d3ue9qfQ+702l93lvKr3Pe1Ppfd6bSu/z3lT+P1BftQZoGYpVAAAAAElFTkSuQmCC" alt="">
</body>
</html>
· 图片裁切
图片在切图网站中,选择切好的样式,并拷贝CSS代码,粘贴到目标图片的样式里就好
图片裁切工具网站,或者谷歌一下CSS Clip Generator
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.meal {
clip-path: polygon(
0% 20%,
60% 20%,
60% 0%,
100% 50%,
60% 100%,
60% 80%,
0% 80%
);
}
</style>
</head>
<body>
<img class="meal" src="images/meal.jpg" alt="a meal" />
</body>
</html>
· 图片滤镜
CSS提供了很多滤镜,具体可以谷歌,这里举一个例子
CSS滤镜展示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.meal:hover {
/* 灰阶滤镜 模糊滤镜*/
filter: grayscale(70%) blur(3px);
}
</style>
</head>
<body>
<img class="meal" src="images/meal.jpg" alt="a meal" />
</body>
</html>
· 支持高分辨率屏
物理分辨率是设备的参数,逻辑分辨率是CSS中使用的标准,像素比DPR可以理解成放大比例,就是一个像素会被放大几倍来显示。
这张meal的图,在iPhone3上是1:1正常显示,但在iPhone4上,按理说不会占满宽度,因为图片像素只有屏幕像素的一半,但因为iPhone4的DPR是2,也就是1个像素会放大2倍显示,所以这样图会占满屏幕宽度,但是又有个问题,因为图片是320x320,被放大两倍后,图会模糊,像素并不能严格匹配iPhone4的屏幕,所以需要更高清的图,也就是我们常用的@2x图或者@3x图来适配DPR2,3的屏幕,或者更高,这种图片处理方式最适合的就是固定宽度的图片
不同分辨率图片生成网站
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.meal {
width: 400px;
}
</style>
</head>
<body>
<img
src="images/meal.jpg"
alt="A bow of salmon and curry"
class="meal"
srcset="images/meal.jpg 1x, images/meal@2x.jpg 2x, images/meal@3x.jpg 3x"
/>
</body>
</html>
· 分辨率转换
在提供了高分辨率图片后,我们可以在不同的屏幕展示合适的图片,这在固定宽度的图片上很好用,但如果图片宽度是变化的,比如全屏展示的图片,就会出现分辨率转换的问题,同样是DPR = 2的显示器,实际分辨率还是会不一样,越大的分辨率,在对图片进行分辨率转换的时候就越消耗资源,所以,需要另外一种方式,可以指定图片的实际宽度,浏览器会自己选择合适的宽度。如果不希望所有屏幕都全屏展示图片,可以使用图片的尺寸集合指定显示宽度
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.meal {
width: 400px;
}
</style>
</head>
<body>
<img
src="images/meal.jpg"
alt="A bow of salmon and curry"
class="meal"
srcset="
images/meal.jpg 400w,
images/meal@2x.jpg 800w,
images/meal@3x.jpg 1200w
"
sizes="
(max-width: 500px) 100vw,
(max-width: 700px) 50vw,
33vw
"
/>
</body>
</html>
· 新图片格式使用webp
这里会用到一个新标签picture
,放置多个图片源供浏览器选择
图片格式转换网站
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- 在支持webp的浏览器中,使用webp图片,否则使用jpg图片 -->
<!-- 若连picture标签都不支持,那就用img标签 -->
<picture>
<source type="image/webp" srcset="images/meal.webp" />
<source type="image/jpeg" srcset="images/meal.jpg" />
<img src="images/meal.jpg" alt="A bow of salmon and curry">
</picture>
</body>
</html>
· 美术指导(其实就是不同屏幕显示不同图片,不知道为啥教程里取这个名字)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<picture>
<!-- 屏幕宽度最大不超过500px的时候,显示裁切过的图片 -->
<source media="(max-width: 500px)" srcset="images/meal-cropped.jpg">
<!-- 屏幕最小宽度大于501px的时候,显示完整图片 -->
<source media="(min-width: 501px)" srcset="images/meal.jpg">
<!-- 不支持picture的标签,显示完整图片 -->
<img src="images/meal.jpg" alt="A bow of salmon and curry">
</picture>
</body>
</html>
· 可缩放矢量图
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
background: url(images/constellation.svg);
}
.ufo {
width: 100px;
}
</style>
</head>
<body>
<img class="ufo" src="images/ufo.svg" alt="UFO">
</body>
</html>
· 图标字体
图标字体网站
在网站中生成图标字体工具集,link到网站中就可以使用,具体空降教程P6-00:56:00
下一篇
H5 Mosh教程笔记 - 表单简介
上一篇
H5 Mosh教程笔记 - 字体简介