新增第231个小实例:文字边框视觉错位

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2023-11-03 15:35:14 +08:00
parent 05e4a90f98
commit 9d63b10fff
3 changed files with 66 additions and 0 deletions

View File

@ -238,6 +238,7 @@
228. HTML5+CSS3小实例具有悬停效果的3D闪耀动画
229. HTML5+CSS3+JS小实例创意罗盘时钟
230. HTML5+CSS3+JS小实例原生JS实现全屏滚动
231. HTML5+CSS3小实例文字边框视觉错位
#### 赞赏作者
![image](https://gitee.com/wyanhui02/html_css_demo/raw/master/images/%E8%B5%9E%E8%B5%8F%E4%BD%9C%E8%80%85/%E8%B5%9E%E8%B5%8F%E7%A0%81.jpg)

51
code/231/231.css Normal file
View File

@ -0,0 +1,51 @@
*{
margin: 0;
padding: 0;
}
body{
background-color: #a4b0be;
}
.container{
position: absolute;
left: 50%;
top: 50%;
/* 居中 */
transform: translate(-50%, -50%);
}
.container span{
font-size: 100px;
font-weight: bold;
color: #fff;
text-shadow: 0 20px 20px #222,
0 40px 60px #222;
}
.container span::before,
.container span::after{
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
padding: 35px 25px;
/* 绑定动画:动画名 时长 线性 无限播放 */
animation: rotate 10s linear infinite;
}
.container span::before{
border-top: 18px solid #208fff;
border-right: 18px solid #208fff;
/* 降低层级 */
z-index: -1;
}
.container span::after{
border-bottom: 18px solid #208fff;
border-left: 18px solid #208fff;
box-shadow: 25px 25px 20px #2f3542;
}
/* 定义旋转动画 */
@keyframes rotate {
to{
transform: translate(-50%, -50%) rotateZ(360deg);
}
}

14
code/231/231.html Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文字边框视觉错位</title>
<link rel="stylesheet" href="231.css">
</head>
<body>
<div class="container">
<span>HELLO WORLD</span>
</div>
</body>
</html>