Common ways for operating CSS

Contents

1 register css custom properties

if ('registerProperty' in CSS) {CSS.registerProperty({ name:'--color', syntax:'< color>', // The list syntax can be represented here:'+', inherits: true, initialValue:'rgba(0, 0, 0, 1)' // initialValue:'rotate(90deg) translateX (5rem)' }) }

2 Get css custom variable

const el = document.querySelector('. card'); const styleMap = el.computedStyleMap(); const computedProp = styleMap.get('--size'); console.log(computedProp); //? CSSUnitValue {unit: "px", value: 10}/ / Or const attributeProp = el.attributeStyleMap.get('--size'); // Both computedStyleMap and attributeStyleMap can be used to get the attribute set, but computedStyleMap is read-only. Parsing the  attribute always returns the pixel value. 

3 Set css custom variables

el.style.setProperty('--size', new CSSUnitValue(computedProp .value,'vw')); const propValue = el.style.getPropertyValue('--size'); console.log(propValue);//? 10vw

Contents

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5729 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.