xxxxxxx
by velo_ninja
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamic Divs</title>
<style>
</style>
</head>
<body>
<script>
let counterItem = 0;
let counterNote = 0;
//-------------------------------------
function createDiv(id, title, color) {
const div = document.createElement('div');
div.id = id;
div.classList.add('cell');
div.textContent = title;
div.style.backgroundColor = color;
div.style.borderColor = color;
div.style.borderRadius = '2px';
div.style.display = 'flex';
div.style.alignItems = 'center';
div.style.justifyContent = 'center';
return div;
}
function createRow(data, parentElement) {
const row = document.createElement('div');
row.classList.add('row');
row.style.display = 'flex';
for (let i = 0; i < data.ids.length; i++) {
const div = createDiv(data.ids[i], data.titles[i], data.colors[i]);
div.style.flexBasis = `${data.percentages[i]}%`;
if (div.id === 'divCounter') {
counterItem++
div.id = 'divCounter' + counterItem;
console.log(div.id);
div.textContent = counterItem;
div.style.padding = "10px";
div.style.color = 'white';
}
else if (div.id === 'divTitle') {
div.id = 'divTitle' + counterItem;
div.textContent = 'Task-Title here...';
div.style.display = 'flex';
div.style.alignItems = 'center';
div.style.justifyContent = 'flex-start';
div.style.padding = '10px';
}
else if...
CSS
.row {
border-bottom: 3px solid black !important;
}
#divTask {
bottom: -5px; /* Adjust this value to control the distance of the underline from the text */
left: 0;
width: 100%;
height: 8px; /* Adjust the thickness of the underline */
background: linear-gradient(to right, rgba(0, 100, 255, 0.5), rgba(100, 250, 55, 0.4)); /* Gradient color */
border-radius: 5px; /* Rounded corners */
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.8); /* Shadow effect */
}
#divNote {
bottom: -5px; /* Adjust this value to control the distance of the underline from the text */
left: 0;
width: 100%;
height: 8px; /* Adjust the thickness of the underline */
background: linear-gradient(to right, rgba(0, 100, 255, 0.5), rgba(100, 250, 55, 0.8)); /* Gradient color */
border-radius: 5px; /* Rounded corners */
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.8); /* Shadow effect */
}