css 中文字旋转,css
下载代码
html
css
js
分享到微信朋友圈
X
html
CSS Animation is
awesome.
beautiful.
creative.
fabulous.
interesting.
css
@import url(https://fonts.googleapis.com/css?family=Lato:600);
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #222;
}
.rotating-text {
font-family: Lato, sans-serif;
font-weight: 600;
font-size: 36px;
color: white;
transform: translateX(-80px);
}
.rotating-text p {
display: inline-flex;
margin: 0;
vertical-align: top;
}
.rotating-text p .word {
position: absolute;
display: flex;
opacity: 0;
}
.rotating-text p .word .letter {
transform-origin: center center 25px;
}
.rotating-text p .word .letter.out {
transform: rotateX(90deg);
transition: 0.32s cubic-bezier(0.6, 0, 0.7, 0.2);
}
.rotating-text p .word .letter.in {
transition: 0.38s ease;
}
.rotating-text p .word .letter.behind {
transform: rotateX(-90deg);
}
.alizarin {
color: #e74c3c;
}
.wisteria {
color: #8e44ad;
}
.peter-river {
color: #3498db;
}
.emerald {
color: #2ecc71;
}
.sun-flower {
color: #f1c40f;
}
JavaScript
var words = document.querySelectorAll(".word");
words.forEach(function (word) {
var letters = word.textContent.split("");
word.textContent = "";
letters.forEach(function (letter) {
var span = document.createElement("span");
span.textContent = letter;
span.className = "letter";
word.append(span);
});
});
var currentWordIndex = 0;
var maxWordIndex = words.length - 1;
words[currentWordIndex].style.opacity = "1";
var rotateText = function () {
var currentWord = words[currentWordIndex];
var nextWord = currentWordIndex === maxWordIndex ? words[0] : words[currentWordIndex + 1];
// rotate out letters of current word
Array.from(currentWord.children).forEach(function (letter, i) {
setTimeout(function () {
letter.className = "letter out";
}, i * 80);
});
// reveal and rotate in letters of next word
nextWord.style.opacity = "1";
Array.from(nextWord.children).forEach(function (letter, i) {
letter.className = "letter behind";
setTimeout(function () {
letter.className = "letter in";
}, 340 + i * 80);
});
currentWordIndex =
currentWordIndex === maxWordIndex ? 0 : currentWordIndex + 1;
};
rotateText();
setInterval(rotateText, 4000);
css 中文字旋转,css相关推荐
- html css中文字段落,css中文字行间距怎么设置?
在网页的布局中几大段文字挤在一起总归是不好看的,这时候我们就需要来设置行间距来让文字看起来不拥挤,也让整个页面看起来美观整洁,那么,行间距该如何设置呢?本篇文章就来给大家介绍一下css行间距的设置方法 ...
- html css中文字段落,css段落文字(中英文混杂)实现两端对齐
今天分享一个小技巧,是中英文两端对齐,只是应对哪些变态的需求.一般情况下还是不推荐使用的,毕竟使用了几句js. 案例如下: 混合使用汉字和英文的段落默认如下: 两边是不对齐的(一般情况下,我们对这种情 ...
- HTML+CSS中 文字两边线水平居中且两边对齐
HTML+CSS中 文字两边线水平居中且两边对齐 HTML+CSS想要文字两边出现水平居中的线且根据盒子的宽度两边对齐,水平居中, 这样的话可以用这样伪类来实现效果. <CSS部分> .t ...
- html怎样让文字自动换行,css中文字自动换行如何实现
css中文字自动换行如何实现 在div css布局中,遇到连续英文字母或连续数字在div.p.h2.h1等盒子里排成一排显示不会自动随盒子宽度限制而自动换行. 当然中文字在DIV或任意盒子中均会自动换 ...
- css中文字段落对齐,CSS段落对齐方式
CSS段落对齐有两种方式:水平对齐和垂直对齐. 1.水平对齐: (1).text-align:left; //左对齐 (2).text-align:right; //右对齐 ...
- CSS中文字间距和行间距
文字间距 1,text-align设置文字布局 即text-align:center文字就会在div中居中停放 2,font-size设置文字的大小 即font-size:20px 文字的大小就是20 ...
- css中repeat用法,CSS background-repeat用法及代码示例
CSS中的background-repeat属性用于水平和垂直重复背景图像.它还决定是否重复background-image. 用法 background-repeat:repeat|repeat-x ...
- css中按钮变色,CSS控制按钮变色(有图有真相)
昨天有一个朋友问我,我网站右上角那几个按钮,鼠标经过时变色是怎么做到的,我答道是用CSS控制 的,他大吃一惊,说还以为我是用javascript来实现的,怎么CSS也可以实现这种特效吗?我无语.. 好 ...
- css中left属性,CSS left属性用法及代码示例
CSS中的left属性用于指定定位元素的水平位置.它对未定位的元素没有影响. 注意: 如果position属性是绝对或固定的,则left属性指定元素左边与其包含块的左边之间的距离. 如果positio ...
最新文章
- oracle如何降低逻辑读,如何降低该SQL的逻辑读
- 深入redis内部之redis启动过程之二
- 聊聊JvmGcMetrics的managementExtensionsPresent
- java执行mongodb语句_java下执行mongodb
- iOS:步进UIStepper、滑动块UISlider、开关UISwitch的基本使用
- Java多线程:线程安全和非线程安全的集合对象
- EF Code First 简单的示例
- 怎么让电脑屏幕一直亮着_电脑屏幕总是闪烁?试试这个方法
- python读取python源代码文件_python 学习源码练习(2)——简单文件读取
- Netbeans Platform的Lookup -- 边学边记
- Frequentist 观点和 Bayesian 观点
- Javascript特效:输入框焦点判断
- 起风了用计算机按,用计算机弹起风了要点那些键
- 可变焦、聚焦摄像头驱动程序-瑞盟 MS41908M
- c++ 聚合/POD/平凡/标准布局 介绍
- [Bug] Spring相关bug收集
- 如何在一夜之间获得成功:我「从无到有」的 5 年 [英文版]
- html点击出现对勾,html , 对勾,警告,错误 三种情况
- pam_limits(crond:session): unknown limit item ‘noproc‘
- 【成为架构师课程系列】高性能系统设计之分布式缓存