HTML、CSS 和响应性参考表
HTML、CSS 和响应性参考表
HTML、CSS 和响应性参考表
这是我收集的所有 HTML 和 CSS 参考资料,可以在研究它们作为路径时用作参考,这里还提供使用响应性的解释。
你可以在我的Github上获取 markdown
目录
HTML
基本 HTML
有用的元素
CSS
基本 CSS
- 盒子模型 - 解释
- 选择器 - 所有伪选择器和30 个常用备忘单
- 定位 - 相对、绝对和其他
- 状态 - 链接|访问|悬停|活动|焦点
- 之前和之后元素 - 参考|应用
- 伪类选择器 - :not | :nth-child |其他
- 特殊函数 - calc() |其他
- 变量 - 参考
定位
动画
图像与转换
样式表单
- 样式输入 - 参考
- 选择器 - :input-placholder | :input-placeholder-shown | :valid | :invalid | :focus
- 其他输入 - 单选按钮、复选框、切换样式
- 下拉菜单 - 参考
有用的属性
- 目标- 以具有 ID 的元素为目标
- 背景剪辑- 使用文本或内容剪辑背景
- 透视- 改变 3D 动画的透视
- 背面可见性- 针对后面的元素
- 溢出- 用于溢出内容
- 背景混合模式、混合模式- 将背景与某些颜色混合,或将文本与背景混合
- 框装饰中断- 修复多行文本的装饰
- 外部形状- 根据图像的形状对齐段落
- 图像滤镜——为图像添加滤镜
- 对象适合- 将图像和视频放入容器中
- 连字符- 用于多行内容
- backdrop-filter - 为背景提供过滤器
响应能力
-
元标记 -
<meta name='viewport' content="width=device-width, initial-scale=1.0">
屏幕宽度使用情况
- 桌面优先:使用最大宽度;(从高到低)
- 移动优先:使用最小宽度(从低到高)
应用媒体查询的顺序
- 基础+排版
- 总体布局
- 网格
- 页面布局
- 成分
处理图像
-
密度切换 -高分辨率(2px 对应 1px)和低分辨率(1px 对应 1px)
<img srcset="img1x.png 1x, img2x.png 2x" alt="Image">
-
艺术指导 -不同屏幕使用不同图像
<picture>
<!-- when lower than 600px -->
<source srcset="imgsmall1x.png 1x, imgsmall2x.png 2x" media="(max-width: 37.5em)">
<!-- using density switching with art directions -->
<img srcset="img1x.png 1x, img2x.png 2x" alt="img">
</picture>
- 分辨率切换 -大屏幕和小屏幕
<!-- in srcset , the images are specified with their original width-->
<img srcset="img1.png 300w, img1-large.png 1000w"
sizes="(max-width: 900px) 20vw, (max-width: 600px) 30vw, 300px">
<!-- in sizes , the screen size is speicified with the image width to be used, last one being the default size -->
- 在 CSS 中处理图像 -媒体查询与屏幕分辨率和宽度相结合
// for resolution greater than 1px and 600px width or webkit is for safari browser
@media (min-resolution: 192pi) and (min-width:600px) ,
(-webkit-min-device-pixel-ratio: 2) and (min-width:600px){
// image you want to set
}
功能查询
- 浏览器
@supports (-webkit-backdrop-filter: blur(10px)) or (backdrop-filter: blur(10px)){
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
//use only if the browser supports these properties
}
- 触摸功能 -这将适用于小屏幕或非悬停屏幕。
@media only screen and (max-width: 56.25em), only screen and (hover:none){}
其他有用的概念
-
优化图像 -通过裁剪或使用Optimizilla
-
搜索引擎优化 -使用元标签
-
类命名约定 - BEM
-
全局重置
* {
margin: 0;
padding: 0;
box-sizing: inherit; //from body element
}
html{
font-size: 62.5%; //defines 1rem everywhere as 10px
}
body{
box-sizing: border-box;
/*
Define project wide font family and size in body selector
*/
}
文章来源:https://dev.to/zinox9/html-css-responsiveness-reference-sheet-45i3