Javascript jQuery css 最小高度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7358083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 01:57:58  来源:igfitidea点击:

jQuery css min-height

javascriptjquerycss

提问by technopeasant

Simple.. I'm running into a syntax error. $('#container').css('min-height', '360');doesn't set a rule, but $('#container').css('height', '360');does.

简单.. 我遇到了语法错误。$('#container').css('min-height', '360');没有制定规则,但$('#container').css('height', '360');有。

Help?

帮助?

回答by r.piesnikowski

First try:

第一次尝试:

$('#container').css('min-height', '360px');

Otherwise try

否则试试

$('#container').attr('style','min-height:360px;other-styles');

回答by BoTheK

use

$('#container').css('min-height', '360px');

回答by HMR

Got to this question looking for jQuery.csswhen passing an object literal.

jQuery.css在传递对象文字时找到了这个问题。

With jQuery 2 I could do:

使用 jQuery 2 我可以做到:

$(selector).css({minHeight:"20px"});

Now I can pass a bunch of things at once:

现在我可以一次传递一堆东西:

$(selector).css({
  minHeight:"20px",
  minWidth:"20px",
  backgroundColor:"yellow",
});