Форум по Javascript
Anonymous
Игра с цветными коробками с низкой непрозрачностью
Сообщение
Anonymous » 24 янв 2025, 08:33
Цветное поле с низкой непрозрачностью
Код: Выделить всё
Dynamic Table
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
table {
border-collapse: collapse;
}
td {
width: 50px;
height: 50px;
text-align: center;
vertical-align: middle;
border: 1px solid #ddd;
cursor: pointer;
}
Код: Выделить всё
< /code>
java script:
const tablecontainer = document.getelementbyid ('table-container'); < /p>
let size = 2; < /p>
function createable (size) {< /p>
const table = document.createElement('table');
table.id = 'dynamicTable';
const backgroundColor = getRandomColor();
for (let i = 0; i < size; i++) {
const row = document.createElement('tr');
for (let j = 0; j < size; j++) {
const cell = document.createElement('td');
cell.style.backgroundColor = backgroundColor;
cell.addEventListener('click', () => handleCellClick(cell));
row.appendChild(cell);
}
table.appendChild(row);
}
return table;
< /code>
} < /p>
function getRandomColor () {< /p>
const letters = '0123456789ABCDEF';
let color = '#';
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
< /code>
} < /p>
Функция случайной Rededuceopacity (таблица) {< /p>
const cells = table.querySelectorAll('td');
const randomIndex = Math.floor(Math.random() * cells.length);
const randomCell = cells[randomIndex];
randomCell.style.opacity = 0.5;
randomCell.classList.add('reduced-opacity');
< /code>
} < /p>
function handlecellclick (cell) {< /p>
if (cell.classList.contains('reduced-opacity') && size < 10) {
size++;
tableContainer.innerHTML = '';
const newTable = createTable(size);
tableContainer.appendChild(newTable);
randomlyReduceOpacity(newTable);
}
}
const InitialTable = createTable(size);
tableContainer.appendChild(initialTable);< /p>
randomlyReduceOpacity(initialTable);
Подробнее здесь:
https://stackoverflow.com/questions/793 ... r-box-game
1737696798
Anonymous
Цветное поле с низкой непрозрачностью [code] Dynamic Table body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } table { border-collapse: collapse; } td { width: 50px; height: 50px; text-align: center; vertical-align: middle; border: 1px solid #ddd; cursor: pointer; } [/code] [code] < /code> java script: const tablecontainer = document.getelementbyid ('table-container'); < /p> let size = 2; < /p> function createable (size) {< /p> const table = document.createElement('table'); table.id = 'dynamicTable'; const backgroundColor = getRandomColor(); for (let i = 0; i < size; i++) { const row = document.createElement('tr'); for (let j = 0; j < size; j++) { const cell = document.createElement('td'); cell.style.backgroundColor = backgroundColor; cell.addEventListener('click', () => handleCellClick(cell)); row.appendChild(cell); } table.appendChild(row); } return table; < /code> } < /p> function getRandomColor () {< /p> const letters = '0123456789ABCDEF'; let color = '#'; for (let i = 0; i < 6; i++) { color += letters[Math.floor(Math.random() * 16)]; } return color; < /code> } < /p> Функция случайной Rededuceopacity (таблица) {< /p> const cells = table.querySelectorAll('td'); const randomIndex = Math.floor(Math.random() * cells.length); const randomCell = cells[randomIndex]; randomCell.style.opacity = 0.5; randomCell.classList.add('reduced-opacity'); < /code> } < /p> function handlecellclick (cell) {< /p> if (cell.classList.contains('reduced-opacity') && size < 10) { size++; tableContainer.innerHTML = ''; const newTable = createTable(size); tableContainer.appendChild(newTable); randomlyReduceOpacity(newTable); } [/code] } const InitialTable = createTable(size); tableContainer.appendChild(initialTable);< /p> randomlyReduceOpacity(initialTable); Подробнее здесь: [url]https://stackoverflow.com/questions/79383319/low-opacity-color-box-game[/url]
0 Ответы
15 Просмотры
Последнее сообщение Anonymous
11 окт 2024, 05:54
Кнопка SwiftUI с низкой непрозрачностью и обычным текстом
Anonymous »
26 дек 2024, 22:44 » в форуме
IOS
Я создаю приложение на SwiftUI и столкнулся с небольшими неудобствами. Я использую кнопки с навигационными ссылками и текстом для перехода на разные страницы. Мне нужно, чтобы круги имели низкую непрозрачность, чтобы вы могли просматривать их, но...
0 Ответы
12 Просмотры
Последнее сообщение Anonymous
26 дек 2024, 22:44
Игра с низкой цветовой коробкой непрозрачно
Anonymous »
24 янв 2025, 08:33 » в форуме
Html
Цветовая коробка с низкой непрозрачностью
Dynamic Table
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
table {
border-collapse: collapse;
}
td {...
0 Ответы
12 Просмотры
Последнее сообщение Anonymous
24 янв 2025, 08:33
Игра с низкой цветовой коробкой непрозрачно
Anonymous »
24 янв 2025, 09:48 » в форуме
Html
Цветовая коробка с низкой непрозрачностью
const tableContainer = document.getElementById('table-container');
let size = 2;
function createTable(size) {
const table = document.createElement('table');
table.id = 'dynamicTable';
const...
0 Ответы
12 Просмотры
Последнее сообщение Anonymous
24 янв 2025, 09:48
0 Ответы
33 Просмотры
Последнее сообщение Anonymous
15 окт 2024, 11:14