Answers for "javascript css properties"

1

access css property using javascript

const element = document.querySelector('.element')
const style = getComputedStyle(element)
Posted by: Guest on November-19-2020
0

javascript style

// background-color
<element>.style.backgroundColor = '#000';
// background
<element>.style.background = '#000';
// color
<element>.style.color = '#fff';
// box-sizing
<element>.style.boxSizing = 'border-box';
// font-family
<element>.style.fontFamily = '\'Times New Roman\', Times, serif';
// font-size
<element>.style.fontSize = '16px';
// margin
<element>.style.margin = 0;
// padding
<element>.style.padding = '20px';
// width
<element>.style.width = '100%';
// height
<element>.style.height = '100%';
// margin-left
<element>.style.marginLeft = 0;
// font-weight
<element>.style.fontWeight = 400;
Posted by: Guest on September-11-2020
1

style through javascript

element.style.backgroundColor = "red";   // set the background color of an element to red
Posted by: Guest on July-10-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language