值得收藏的8个实用CSS效果代码(分享)
时间:2021-11-05
来源:互联网
标签:
今天PHP爱好者给大家带来本篇文章分享8个CSS开发者必须知道的有趣CSS效果代码,值得收藏,大家一起来看看吧!
1 更改输入框的光标颜色
MDN:
caret-color
属性用来定义插入光标(caret)的颜色,这里说的插入光标,就是那个在网页的可编辑器区域内,用来指示用户的输入具体会插入到哪里的那个一闪一闪的形似竖杠|
的东西。(学习视频分享:css视频教程)
例如我们将光标设置为蓝色
input{
caret-color:blue;
}
2 一行代码禁止用户选择文本
user-select: none;
3 内容选中的效果
这里设置文本选中的颜色是绿色
.p::selection {
background-color: green;
color: #fff;
}
4 居中最好用的三行代码
display: flex;
align-items: center;
justify-content: center;
示例:
.father{
width: 200px;
height: 200px;
border: solid #000 2px;
display: flex;
align-items: center;
justify-content: center;
}
.child{
width: 50px;
height: 50px;
border: solid red 2px;
}
5 平滑滚动
scroll-behavior: smooth;
6 用户可调整元素的大小
resize: both;
注意:resize
除非将overflow
属性设置为 以外的其他visible
值,否则什么都不做,visible是大多数元素的默认值。
.father{
width: 200px;
height: 200px;
border: solid #000 2px;
display: flex;
align-items: center;
justify-content: center;
resize: both;
overflow: auto;
}
7 图片作为光标
cursor: url(), auto;
8 打字机效果
.container {
height: 500px;
display: flex;
align-items: center;
justify-content: center;
}
.typing {
width: 220px;
animation: typing 2s steps(8), blink 0.5s step-end infinite alternate;
white-space: nowrap;
overflow: hidden;
border-right: 3px solid;
font-family: monospace;
font-size: 2em;
}
@keyframes typing {
from {
width: 0;
}
}
@keyframes blink {
50% {
border-color: transparent;
}
}
<p class="container">
<p class="typing">我是用打字机效果</p>
</p>
以上就是值得收藏的8个实用CSS效果代码(分享)的详细内容,更多请关注php爱好者其它相关文章!
-
访问网站出现nginx怎么解决?welcome to nginx!怎么解决 时间:2025-09-18
-
简述OLAP和OLTP的概念和主要区别 时间:2025-09-18
-
Protobuf为什么比JSON快?两者之间的性能对比 时间:2025-09-18
-
Wifi协议802.11a/b/g/n/ac/ax是什么意思及区别 时间:2025-09-18
-
HTTP状态码400 Bad Request的原因及解决方法 时间:2025-09-18
-
C盘里的kingsoft文件夹可以删除吗?kingsoft文件夹有什么用? 时间:2025-09-18
今日更新
-
荒野起源荒野试炼怎么玩-荒野试炼玩法详细
阅读:18
-
鸣潮每日任务怎么开-鸣潮每日任务完成方法
阅读:18
-
鼠标特效代码大全:让你的网页互动更炫酷的30种实现方案
阅读:18
-
10个超酷鼠标特效代码合集 让你的网页瞬间提升交互体验
阅读:18
-
异环12层试炼怎么打-异环手游试炼塔通关
阅读:18
-
梦幻模拟战女神的试炼怎么打-速通打法详解
阅读:18
-
鸣潮每日任务有哪些-鸣潮每日必做事项
阅读:18
-
高效掌握鼠标手势操作技巧 提升电脑办公效率必备指南
阅读:18
-
如何调整鼠标速度?快速优化鼠标灵敏度的实用技巧
阅读:18
-
群星纪元每日任务有哪些-每日任务内容
阅读:18