Htmlcssjsornek
Htmlcssjsornek
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
transition: background-color 0.8s;
}
.container {
text-align: center;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
</style>
<div class="container">
<p id="pp">Arka Plan Rengi Değiştirici</p>
<button id="changeColorBtn">Rengi Değiştir</button>
<p><span id="boyut">0</span></p>
<script>
const button = document.getElementById("changeColorBtn");
const heading =document.getElementById("pp")
button.addEventListener("click", function() {
const colors = ["#FF5733", "#33FF57", "#3357FF", "#FF33A1", "#FF8F33"];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
const fontsz=(Math.floor(Math.random() * 30) + 10)
document.body.style.backgroundColor = randomColor;
heading.style.fontSize=fontsz+"px"
document.getElementById("boyut").innerHTML =fontsz+"px"
});
</script>
</div>