文本选取框被切断
Text Marquee is cutting off
我必须使用带有相当长的文本字符串的选取框。我已经用几种不同的方式处理了这段代码,但最后,文本总是在几个词(或第一行)之后被截断。我需要完整的所有文本才能继续滚动。如果我们能将它保持在 CSS 之内,那就太理想了。谢谢!
你可以在这里看到:http://braidsmusic.com/test
.scroll-left {
height: 100px;
overflow: hidden;
position: relative;
}
.scroll-left h1 {
position: absolute;
width: 150%;
height: 100%;
margin: 0;
line-height: 50px;
text-align: center;
/* Starting position */
-moz-transform: translateX(100%);
-webkit-transform: translateX(100%);
transform: translateX(100%);
/* Apply animation to this element */
-moz-animation: scroll-left 10s linear infinite;
-webkit-animation: scroll-left 10s linear infinite;
animation: scroll-left 10s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes scroll-left {
0% {
-moz-transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%);
}
}
@-webkit-keyframes scroll-left {
0% {
-webkit-transform: translateX(100%);
}
100% {
-webkit-transform: translateX(-100%);
}
}
@keyframes scroll-left {
0% {
-moz-transform: translateX(100%);
/* Browser bug fix */
-webkit-transform: translateX(100%);
/* Browser bug fix */
transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%);
/* Browser bug fix */
-webkit-transform: translateX(-100%);
/* Browser bug fix */
transform: translateX(-100%);
}
}
<div class="scroll-left">
<h1 style="color: #ccc; line-height:90px;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</h1>
</div>
- 滚动左宽度自动填充文本宽度。所以使用适合内容;
- 将起始位置更改为 30%
body{
overflow-x:hidden;
}
.scroll-left {
height:auto;
width:fit-content;
}
.scroll-left h1 {
height:auto;
margin: 0;
/* Starting position */
-moz-transform: translateX(30%);
-webkit-transform: translateX(30%);
transform: translateX(30%);
/* Apply animation to this element */
-moz-animation: scroll-left 30s linear infinite;
-webkit-animation: scroll-left 30s linear infinite;
animation: scroll-left 30s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes scroll-left {
0% {
-moz-transform: translateX(30%);
}
100% {
-moz-transform: translateX(-100%);
}
}
@-webkit-keyframes scroll-left {
0% {
-webkit-transform: translateX(30%);
}
100% {
-webkit-transform: translateX(-100%);
}
}
@keyframes scroll-left {
0% {
-moz-transform: translateX(30%);
/* Browser bug fix */
-webkit-transform: translateX(30%);
/* Browser bug fix */
transform: translateX(30%);
}
100% {
-moz-transform: translateX(-100%);
/* Browser bug fix */
-webkit-transform: translateX(-100%);
/* Browser bug fix */
transform: translateX(-100%);
}
}
<div class="scroll-left">
<h1 style="color: #ccc; white-space:nowrap;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.</h1>
</div>
我必须使用带有相当长的文本字符串的选取框。我已经用几种不同的方式处理了这段代码,但最后,文本总是在几个词(或第一行)之后被截断。我需要完整的所有文本才能继续滚动。如果我们能将它保持在 CSS 之内,那就太理想了。谢谢!
你可以在这里看到:http://braidsmusic.com/test
.scroll-left {
height: 100px;
overflow: hidden;
position: relative;
}
.scroll-left h1 {
position: absolute;
width: 150%;
height: 100%;
margin: 0;
line-height: 50px;
text-align: center;
/* Starting position */
-moz-transform: translateX(100%);
-webkit-transform: translateX(100%);
transform: translateX(100%);
/* Apply animation to this element */
-moz-animation: scroll-left 10s linear infinite;
-webkit-animation: scroll-left 10s linear infinite;
animation: scroll-left 10s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes scroll-left {
0% {
-moz-transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%);
}
}
@-webkit-keyframes scroll-left {
0% {
-webkit-transform: translateX(100%);
}
100% {
-webkit-transform: translateX(-100%);
}
}
@keyframes scroll-left {
0% {
-moz-transform: translateX(100%);
/* Browser bug fix */
-webkit-transform: translateX(100%);
/* Browser bug fix */
transform: translateX(100%);
}
100% {
-moz-transform: translateX(-100%);
/* Browser bug fix */
-webkit-transform: translateX(-100%);
/* Browser bug fix */
transform: translateX(-100%);
}
}
<div class="scroll-left">
<h1 style="color: #ccc; line-height:90px;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</h1>
</div>
- 滚动左宽度自动填充文本宽度。所以使用适合内容;
- 将起始位置更改为 30%
body{
overflow-x:hidden;
}
.scroll-left {
height:auto;
width:fit-content;
}
.scroll-left h1 {
height:auto;
margin: 0;
/* Starting position */
-moz-transform: translateX(30%);
-webkit-transform: translateX(30%);
transform: translateX(30%);
/* Apply animation to this element */
-moz-animation: scroll-left 30s linear infinite;
-webkit-animation: scroll-left 30s linear infinite;
animation: scroll-left 30s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes scroll-left {
0% {
-moz-transform: translateX(30%);
}
100% {
-moz-transform: translateX(-100%);
}
}
@-webkit-keyframes scroll-left {
0% {
-webkit-transform: translateX(30%);
}
100% {
-webkit-transform: translateX(-100%);
}
}
@keyframes scroll-left {
0% {
-moz-transform: translateX(30%);
/* Browser bug fix */
-webkit-transform: translateX(30%);
/* Browser bug fix */
transform: translateX(30%);
}
100% {
-moz-transform: translateX(-100%);
/* Browser bug fix */
-webkit-transform: translateX(-100%);
/* Browser bug fix */
transform: translateX(-100%);
}
}
<div class="scroll-left">
<h1 style="color: #ccc; white-space:nowrap;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.</h1>
</div>