Javascript 复活节彩蛋-字母间距
我做了一个小复活节彩蛋。当您将鼠标悬停在Javascript 复活节彩蛋-字母间距,javascript,jquery,css,Javascript,Jquery,Css,我做了一个小复活节彩蛋。当您将鼠标悬停在h1标题上时,将创建字母,并将动画字母放置在页面底部。我想随着秋天的到来,在字母之间创造更多的间隔,这样它们就不会混在一起了 为此,我做了: myspan.css({ "color" : "Navy", "position": "absolute", "margin" : "20px",
h1
标题上时,将创建字母,并将动画字母放置在页面底部。我想随着秋天的到来,在字母之间创造更多的间隔,这样它们就不会混在一起了
为此,我做了:
myspan.css({
"color" : "Navy",
"position": "absolute",
"margin" : "20px",
"padding" : "20px",
"left": $(this).position().left,
"top": parent.height()
});
但它不起作用。有什么想法吗?代码如下:
$(".title").lettering(); //splits H1 letters into individual spans
$("h1 span").mouseenter(function () {
var colors = ["White"],
rand = Math.floor((Math.random()*colors.length-1)+1),
string = "National Champs!",
letter = string.charAt(index),
myspan = $(document.createElement('span')),
parent = $(this).parent(),
val = $(this);
if (index >= string.length) {
index = 0;
}
else {
index++;
}
myspan.append(letter);
parent.append(myspan);
myspan.css({
"color" : "Navy",
"position": "absolute",
"margin" : "20px",
"padding" : "20px",
"left": $(this).position().left,
"top": parent.height()
});
myspan.animate({"top": $(window).outerHeight()}, 9000, "linear", function() {
$(this).remove();
});
val.css({"color" : colors[rand]});
setTimeout(function() {
val.css({"color" : "black"});
val.css({"font-size" : 35});
//index =0;
},2000);
});
编辑: 是的
这不起作用使用css属性
字母间距
可能会有所帮助
letter-spacing:2px
使用css属性
字母间距可能会有所帮助
letter-spacing:2px
使用css属性字母间距可能会有所帮助
letter-spacing:2px
使用css属性字母间距可能会有所帮助
letter-spacing:2px
您需要为字母间距
提供单位,仅值2
并不意味着什么。我假设您考虑的是像素,因此在本例中,这将是:
myspan.css({
"color" : "Navy",
"position": "absolute",
"letter-spacing" : "2px",
"left": $(this).position().left,
"top": parent.height()
});
请检查此项:您需要提供字母间距的单位
,值2
本身并不意味着什么。我假设您考虑的是像素,因此在本例中,这将是:
myspan.css({
"color" : "Navy",
"position": "absolute",
"letter-spacing" : "2px",
"left": $(this).position().left,
"top": parent.height()
});
请检查此项:您需要提供字母间距的单位
,值2
本身并不意味着什么。我假设您考虑的是像素,因此在本例中,这将是:
myspan.css({
"color" : "Navy",
"position": "absolute",
"letter-spacing" : "2px",
"left": $(this).position().left,
"top": parent.height()
});
请检查此项:您需要提供字母间距的单位
,值2
本身并不意味着什么。我假设您考虑的是像素,因此在本例中,这将是:
myspan.css({
"color" : "Navy",
"position": "absolute",
"letter-spacing" : "2px",
"left": $(this).position().left,
"top": parent.height()
});
请检查以下内容:我做得不对吗?请看上面我做得不对吗?请看上面我做得不对吗?请看上面我做得不对吗?请参见上文是的,我的代码中有px
。。。不知什么原因,我忘了把它贴在这里。它仍然不能用。是的,我的代码中有px
。。。不知什么原因,我忘了把它贴在这里。它仍然不能用。是的,我的代码中有px
。。。不知什么原因,我忘了把它贴在这里。它仍然不能用。是的,我的代码中有px
。。。不知什么原因,我忘了把它贴在这里。这仍然不起作用。