Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function copyStylesForCSS(element) {
- const styles = window.getComputedStyle(element);
- let styleString = '';
- // Список стилей, которые нужно включить
- const allowedStyles = [
- 'min-height', 'max-width', 'height', 'width', 'padding', 'margin',
- 'grid-gap', 'gap', 'display', 'grid-template-areas', 'grid-template-rows',
- 'grid-template-columns', 'grid-area', 'flex-direction', 'background-color',
- 'color', 'border-bottom', 'background', 'background-repeat', 'background-position',
- 'font-family', 'font-style', 'font-weight', 'font-size', 'line-height',
- 'letter-spacing', 'text-decoration', 'text-overflow', 'overflow-wrap',
- 'position', 'top', 'left', 'right', 'z-index', 'border-radius', 'transition',
- 'cursor', 'box-shadow', 'overflow-wrap', 'opacity', 'overflow', 'cursor', 'grid-area'
- ];
- for (let i = 0; i < styles.length; i++) {
- const styleName = styles[i];
- const styleValue = styles.getPropertyValue(styleName);
- // Проверяем, что стиль не равен его значению по умолчанию и входит в список разрешенных стилей
- if (allowedStyles.includes(styleName) && styleValue && styleValue !== 'auto' && styleValue !== 'none' && styleValue !== 'normal') {
- styleString += `${styleName}: ${styleValue};\n`;
- }
- }
- console.log(styleString);
- }
- const item = document.querySelector('.vvp-header-menu__item');
- copyStylesForCSS(item);
Advertisement
Add Comment
Please, Sign In to add comment