The csstext of CSS

Source: Internet
Author: User

Change element style

<div style= "width:100px;height:100px;text-align:center;line-height:100px;" > This is        div
</div>

We assign a value to the Style property directly if the style of the general change is less.

Div.style.width = "200px";d iv.style.height = "200px";d iv.style.lineHeight = "200px";

But once you have a lot of styles to change, you can use Csstext to set

Div.style.cssText = "width:200px;height:200px;line-height:200px";

However, Csstext overrides the inline style, does not overwrite the style within the <style> tag, does not overwrite the external style, so in order to solve this problem, style overlay is used.

Div.style.cssText + = "width:200px;height:200px;line-height:200px";

However, browser Div.style.cssText below IE9 will omit the last semicolon in Csstext

Console.log (Div.style.cssText);
The result: height:100px; width:100px; Text-align:center; line-height:100px; Background-color:red

So in order to solve this small problem in IE

Div.style.cssText + = "; width:200px;height:200px;line-height:200px";

The csstext of CSS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.