HTML 实现文字沿圆形外侧边旋转效果
<!DOCTYPE html>
<html>
<head>
<title>旋转文本</title>
<style type="text/css">
.container {
position: relative;
width: 200px;
height: 200px;
border: 1px solid black;
border-radius: 50%;
overflow: hidden;
}
.text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 20px;
font-weight: bold;
text-align: center;
animation: rotate 5s linear infinite;
}
@keyframes rotate {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
}
}
</style>
</head>
<body>
<div class='container'>
<div class='text'>
<input type='text' id='inputText' placeholder='请输入文字'>
<button onclick='setText()'>旋转</button>
</div>
</div>
<script type='text/javascript'>
function setText() {
var text = document.getElementById('inputText').value;
document.querySelector('.text').innerHTML = text;
}
</script>
</body>
</html>
原文地址: http://www.cveoy.top/t/topic/nWeQ 著作权归作者所有。请勿转载和采集!