使用动画调整字体大小,jquery
Resizing font with animation, jquery
当您阅读此问题的 title
时,您已经知道我想做什么。
我已经阅读了有关 resizing with animation
的内容,但无法加速解决我的问题。如果你有时间查看我的代码:
这些是我用于整个功能的按钮。
需要调整大小的文本的 ID 是 ("fontce").
<form id="forma">
<p>Големина на фонт</p>
<button type="button" value="Pocetna" onclick="Pocetna()">Почетна</button>
<button type="button" value="Zgolemi" onclick="Zgolemi()">Зголеми</button>
<button type="button" value="Namali" onclick="Namali()">Намали</button>
</form>
这个功能我要让字体恢复正常
var s = $("#fontce").css('fontSize');
function Pocetna() {
jQuery(document).ready(function () {
("#fontce").animate({
"fontSize":s
},1000);
});
以及放大字体的功能:
function Zgolemi()
{
jQuery(document).ready(function () {
var s1 = $(this.fontSize);
("#fontce").animate({
"fontSize":s1*1.5
},1000);
})
}
字体变小的功能和上面的相反
let s = $("#fontce").css('fontSize').slice(0, -2);
$("#pocetna").click(Pocetna);
$("#zgolemi").click(Zgolemi);
$("#namali").click(Namali);
function Pocetna() {
$("#fontce").animate({
fontSize: s
}, 1000);
}
function Zgolemi() {
let s1 = $("#fontce").css('fontSize').slice(0, -2);
console.log(s1)
$("#fontce").animate({
fontSize: s1 * 1.5
}, 1000);
}
function Namali() {
let s2 = $("#fontce").css('fontSize').slice(0, -2);
console.log(s2)
$("#fontce").animate({
fontSize: s2 / 1.5
}, 1000);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="forma">
<p>Големина на фонт</p>
<button type="button" value="Pocetna" id="pocetna">Почетна</button>
<button type="button" value="Zgolemi" id="zgolemi">Зголеми</button>
<button type="button" value="Namali" id="namali">Намали</button>
</form>
<p id="fontce">
To connect to the internet, you'll need an Internet service provider (ISP)
and some hardware:ISP. An ISP is a company that gives you access to the Internet.
You sign up for an account with an ISP just as you do for telephone service or utilities.
ISPs are usually phone companies( for a DSL or fiber optic connection)
or TV providers(for cable or satellite connection).<br>
Hardware. For a broadband connection, such as DSL, fiber optic, or cable,
you'll need a boradband modem. This might be included as part of the start-up hardware from your ISP
wgen you sign up for a broadband account. If you play to share Internet access with multiple PCs by
using a home network, you'll also need a router.
</p>
当您阅读此问题的 title
时,您已经知道我想做什么。
我已经阅读了有关 resizing with animation
的内容,但无法加速解决我的问题。如果你有时间查看我的代码:
这些是我用于整个功能的按钮。 需要调整大小的文本的 ID 是 ("fontce").
<form id="forma">
<p>Големина на фонт</p>
<button type="button" value="Pocetna" onclick="Pocetna()">Почетна</button>
<button type="button" value="Zgolemi" onclick="Zgolemi()">Зголеми</button>
<button type="button" value="Namali" onclick="Namali()">Намали</button>
</form>
这个功能我要让字体恢复正常
var s = $("#fontce").css('fontSize');
function Pocetna() {
jQuery(document).ready(function () {
("#fontce").animate({
"fontSize":s
},1000);
});
以及放大字体的功能:
function Zgolemi()
{
jQuery(document).ready(function () {
var s1 = $(this.fontSize);
("#fontce").animate({
"fontSize":s1*1.5
},1000);
})
}
字体变小的功能和上面的相反
let s = $("#fontce").css('fontSize').slice(0, -2);
$("#pocetna").click(Pocetna);
$("#zgolemi").click(Zgolemi);
$("#namali").click(Namali);
function Pocetna() {
$("#fontce").animate({
fontSize: s
}, 1000);
}
function Zgolemi() {
let s1 = $("#fontce").css('fontSize').slice(0, -2);
console.log(s1)
$("#fontce").animate({
fontSize: s1 * 1.5
}, 1000);
}
function Namali() {
let s2 = $("#fontce").css('fontSize').slice(0, -2);
console.log(s2)
$("#fontce").animate({
fontSize: s2 / 1.5
}, 1000);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="forma">
<p>Големина на фонт</p>
<button type="button" value="Pocetna" id="pocetna">Почетна</button>
<button type="button" value="Zgolemi" id="zgolemi">Зголеми</button>
<button type="button" value="Namali" id="namali">Намали</button>
</form>
<p id="fontce">
To connect to the internet, you'll need an Internet service provider (ISP)
and some hardware:ISP. An ISP is a company that gives you access to the Internet.
You sign up for an account with an ISP just as you do for telephone service or utilities.
ISPs are usually phone companies( for a DSL or fiber optic connection)
or TV providers(for cable or satellite connection).<br>
Hardware. For a broadband connection, such as DSL, fiber optic, or cable,
you'll need a boradband modem. This might be included as part of the start-up hardware from your ISP
wgen you sign up for a broadband account. If you play to share Internet access with multiple PCs by
using a home network, you'll also need a router.
</p>