Jquery 函数 CSS

use*_*504 3 javascript css jquery

我想知道这个脚本是否不好,不适合我:

\n\n
jQuery(".template_content_img").css({\n    width: "50%",\n    height: "150px",\n    //// Here gives me error \n    font-size: "12px",\n    margin-bottom: "23px",\n});\n
Run Code Online (Sandbox Code Playgroud)\n\n

我不\xc2\xb4t 知道问题\xc2\xb4s 是“width:200px”还是“width”,“150px”

\n\n

这些是我的伙计们,另一方面,我看到很多人也使用 animate 来实现此目的,而不使用 css,但是为什么你认为 animate 创建效果和 div 转换,仅此我需要更改一些内容,但它不起作用。

\n\n

问候 !!!

\n

Sha*_*dow 5

检查jQuery .css文档

jQuery(".template_content_img").css({
    "width": "50%",
    "height": "150px"
});

jQuery(".template_img").css({
    "width": "70%",
    "height": "100px"
});
Run Code Online (Sandbox Code Playgroud)

编辑:如果你想添加font-sizemargin-bottom,只需使用经典的 CSS 属性/值

jQuery(".template_content_img").css({
    "width": "50%",
    "height": "150px"
    "font-size": "12px",
    "margin-bottom": "23px",
});
Run Code Online (Sandbox Code Playgroud)