<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div class="block">text</div>
<div class="block">text</div>
<div class="inline-block">text</div>
<div class="inline-block">text</div>
<script src="./less1.js"></script>
</body>
</html>
.block {display: block;}
.inline-block {display: inline-block;}
Можно как-то проще добавить стили к классам?
((el) => {
el.forEach((el) => {
const select = document.getElementsByClassName(el);
if (select.length !== 0) {
document
.querySelectorAll("." + el)
.forEach((element) => (element.style.display = el));
}
});
})([
"block",
"inline-block",
"inline",
"flex",
"inline-flex",
"table",
"inline-table",
"table-caption",
]);