<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>文本溢出</title>
<style>
.wrap {
position: relative;
150px;
overflow: hidden;
background: #eee;
}
p {
display: inline-block;
white-space: nowrap;
}
p:hover {
animation: move 1.5s infinite alternate linear;
}
@keyframes move {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(calc(-100% + 150px), 0);
}
}
</style>
</head>
<body>
<div class="wrap">
<p title="我的宽度是正常宽度">我的宽度是正常宽度</p>
<p class="scroll" title="我的宽度是溢出了一小部分">
我的宽度是溢出了一小部分
</p>
<p class="scroll" title="我的宽度是溢出了溢出了很大一部分">
我的宽度是溢出了溢出了很大一部分
</p>
</div>
</body>
</html>