出于某种原因,我的文本旋转器在顶部显示鬼幻影边界线,有时在左侧显示。此问题仅出现在Chrome浏览器上,如果您在Firefox和Safari上进行检查,则一切看起来都很棒。
如何修复仅在Chrome浏览器上出现的幻像边框?
var TxtRotate = function(el, toRotate, period, speed) {
this.toRotate = toRotate;
this.el = el;
this.loopNum = 0;
this.period = parseInt(period, 10) || 2000;
this.txt = '';
this.tick();
this.speed = parseInt(speed, 10) || 300;
this.isDeleting = false;
};
TxtRotate.prototype.tick = function() {
var i = this.loopNum % this.toRotate.length;
var fullTxt = this.toRotate[i];
if (this.isDeleting) {
this.txt = fullTxt.substring(0, this.txt.length - 1);
} else {
this.txt = fullTxt.substring(0, this.txt.length + 1);
}
this.el.innerHTML = '<span class="wrap">'+this.txt+'</span>';
var that = this;
var delta = this.speed - Math.random() * 100;
if (this.isDeleting) { delta /= 2; }
if (!this.isDeleting && this.txt === fullTxt) {
setTimeout(function(){
delta = that.period;
that.isDeleting = true;
},2000);
} else if (this.isDeleting && this.txt === '') {
this.isDeleting = false;
this.loopNum++;
delta = 500;
}
setTimeout(function() {
that.tick();
}, delta);
};
window.onload = function() {
var elements = document.getElementsByClassName('txt-rotate');
for (var i=0; i<elements.length; i++) {
var toRotate = elements[i].getAttribute('data-rotate');
var period = elements[i].getAttribute('data-period');
var speed = elements[i].getAttribute('data-speed');
if (toRotate) {
new TxtRotate(elements[i], JSON.parse(toRotate), period, speed);
}
}
};
&#13;
body {
background: #1e1f20;
color: #f6f6f6;
font-size: 16px;
}
body h1 {
font-family: 'Lato', sans-serif;
font-size: 2.5rem;
font-weight: 300;
}
body .container {
max-width: 800px;
text-align: center;
margin: 50px auto;
}
&#13;
<div class="container">
<h1>Linux Quotes: <span class="txt-rotate" data-period="150" data-speed="100" data-rotate="[ "The Linux philosophy is `Laugh in the face of danger`. Oops. Wrong One. `Do it yourself`. Yes, that`s it. Linus Torvalds", "All the best people in life seem to like LINUX. Steve Wozniak", "If Microsoft ever does applications for Linux it means I`ve won. Linus Torvalds", "I currently use Ubuntu Linux, on a standalone laptop - it has no Internet connection. I occasionally carry flash memory drives between this machine and the Macs that I use for network surfing and graphics; but I trust my family jewels only to Linux. Donald Knuth", "Android is very different from the GNU/Linux operating system because it contains very little of GNU. Indeed, just about the only component in common between Android and GNU/Linux is Linux, the kernel. Richard Stallman" ]"></span>
</h1>
</div>
&#13;
stackoverflow要求我添加有关此问题的更多详细信息,因此本文仅将此问题移至live =)
PS:问题仅出在Chrome浏览器上! 版本63.0.3239.84(官方构建)(64位)
答案 0 :(得分:1)
尝试禁用扩展程序,有时会导致奇怪的行为。