简体   繁体   English

通过javaScript或jQuery修改CSS Flexbox属性值

[英]Modify CSS Flexbox Property value via javaScript or jQuery

I am building a website using flexbox for the first time. 我是第一次使用flexbox建立网站。 I came across a situation where I want to change a css property via javaScript or jQuery but I don't know how. 我遇到一种情况,我想通过javaScript或jQuery更改css属性,但我不知道如何。

example: 例:

#elementId {
/*flex-item*/
align-items: center;
}

I want to change to: 我想更改为:

align-items: flex-start;

Is it possible via javaScript or jQuery? 是否可以通过javaScript或jQuery?

这可以在jQuery中实现:

$("#elementId").css("align-items", "flex-start");

The answer is Yes you can . 答案是可以

Here is the syntax. 这是语法。

$(Selector).css("style-attribute", "value");

Know more on jQuery selectors here, http://www.w3schools.com/jquery/jquery_ref_selectors.asp 在此处了解有关jQuery选择器的更多信息, http://www.w3schools.com/jquery/jquery_ref_selectors.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM