Newer
Older
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
h1 {
display: none;
}
.controls {
display: flex;
gap: 10px;
position: absolute;
left: 50%;
transform: translateX(-50%);
padding: 1em 0 0 0;
}
.controls label {
display: flex;
align-items: center;
}
.controls input {
margin-right: 15px;
padding: 5px;
font-size: 16px;
}
.aquarium {
width: 100%;
height: auto;
}
<div class="controls">
<label for="heightInput">Height:</label>
<input type="text" id="heightInput" placeholder="e.g., 200px, 50%, auto">
<label for="widthInput">Width:</label>
<input type="text" id="widthInput" placeholder="e.g., 300px, 75%, auto">
</div>
<img class="aquarium" src="/medien/makerspace-logo-visionen.png"></img>
<script>
// Wait for the DOM content to load before running the script
document.addEventListener('DOMContentLoaded', () => {
// Get references to the height and width input elements
const heightInput = document.getElementById('heightInput');
const widthInput = document.getElementById('widthInput');
// Get a reference to the element with the class 'aquarium'
const aquarium = document.querySelector('.aquarium');
// Function to update the aquarium's height
heightInput.addEventListener('input', () => {
// Get the input value
const newHeight = heightInput.value;
// Set the aquarium's height to the input value
aquarium.style.height = newHeight;
});
// Function to update the aquarium's width
widthInput.addEventListener('input', () => {
// Get the input value
const newWidth = widthInput.value;
// Set the aquarium's width to the input value
aquarium.style.width = newWidth;
});
});
</script>