如何在我的css樣式表中分配jquery函數?例如。我有以下css如何將jquery函數分配給css樣式表
div{width: 300px; height: 200px; background-color: red;}
是這樣嗎?
div{width: $func_width; height: $func_height; background-color: $func_color;}
如何在我的css樣式表中分配jquery函數?例如。我有以下css如何將jquery函數分配給css樣式表
div{width: 300px; height: 200px; background-color: red;}
是這樣嗎?
div{width: $func_width; height: $func_height; background-color: $func_color;}
不,你不能。更好的嘗試jquery css
$('div').css({'width':$func_width,'height': $func_height,'background-color': $func_color});
你不能那樣做。但是,您可以將這些函數動態地分配給使用jQuery的HTML元素。
試試這個
$(document).ready(function(){
$('div').css({'width':$func_width,'height': $func_height,'background-color': $func_color});
// of you can use
$('div').css('width' , $func_width);
$('div').css('height' , $func_heigh);
});
希望這將有助於
簡短的回答:你不能。抱歉。 –
使用SASS [Sass是CSS的擴展,爲基本語言增添了力量和優雅] – grigno
您需要在javascript中執行此操作,javascript代表javascript,css代表僅適用於css。 – jcubic