为了账号安全,请及时绑定邮箱和手机立即绑定

jquery操作样式时什么时候都要加 "px"?引号什么时候用?请看带下划线的代码

if(board[i][j] == 0){

theNumberCell.css("width","0px");

theNumberCell.css("height","0px");

theNumberCell.css("top",getPosTop(i,j)+cellSideLength/2);

theNumberCell.css("left",getPosLeft(i,j)+cellSideLength/2);

}

else{

theNumberCell.css("width",cellSideLength);

theNumberCell.css("height",cellSideLength);

theNumberCell.css("top",getPosTop(i,j));

theNumberCell.css("left",getPosLeft(i,j));

theNumberCell.css("background-color",getNumberBackgroundColor(board[i][j]));

theNumberCell.css("color",getNumberColor(board[i][j]));

theNumberCell.text(getNumberText(board[i][j]));

}


hasConflicted[i][j] = false;

}

$(".number-cell").css("line-height",cellSideLength+"px");

$(".number-cell").css("font-size",0.6*cellSideLength+"px");


正在回答

3 回答

不好意思,看见了,第一次还真没注意到

dwnlpesglslbmucozrgspzx

0 回复 有任何疑惑可以回复我~

这个我也有疑问,本站jquery教程里面讲的是,css的值为数字的时候,会自动把数字转换为字符串并在后面加上“px”。所以加不加“px”都是可以的。但是我不明白为什么最后面font-size不加px就没事但line-heignt不加px就会失败。希望有高手能回答

1 回复 有任何疑惑可以回复我~

值就用px.变量就不加了,变量加了就是字符串了呀

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

jquery操作样式时什么时候都要加 "px"?引号什么时候用?请看带下划线的代码

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信