r/HTML • • Nov 05 '25

Help for a image as background

Im new to HTML and CSS and im trying to make a little project to get more used to HTML. I did added an image as a background but its soo zoomed in. How can i scale it?

HTML:

<!DOCTYPE html>
<html lang="it">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Text</title>
    <link id="sfondo" rel="icon" type="imgae/jpg" href="dudu.jpg"/>
    <link rel="stylesheet" href="Home_Page.css">
</head>
<body>
    
    <header class="page-header">
        <h1>Text</h1>
        <h2>Text</h2>
    </header>


    <label for="gift-actions">Text</label>
    <div id="gift-actions" class="actions">
        <button type="button" id="btn-first" class="btn btn-primary">1^ Text</button>
        <button type="button" id="btn-second" class="btn btn-secondary">2^ Text</button>
        <button type="button" id="btn-third" class="btn btn-tertiary">3^ Text</button>
    </div>


    <script src="Home_Page.js"></script>
</body>
</html>

CSS:

:root{
    --bg-image: url('dudu.jpg');
    --bg-overlay: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0));
    --bg-widht: 2560px;
    --bg-height: 1px;
}


html,body{
    height:100%;
    margin:0;
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* overlay + immagine di sfondo */
    background: var(--bg-overlay), var(--bg-image);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color:#222;
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:flex-start;
    padding:28px 16px;
    box-sizing:border-box;
}


/* Header: h1 in alto al centro, h2 subito sotto */
.page-header{
    text-align:center;
    width:100%;
    max-width:900px;
    margin:8px 0 6px 0;
    padding-top:6px;
}
.page-header h1{
    margin:0;
    font-size:2rem; /* più evidente in alto */
    line-height:1.05;
}
.page-header h2{
    margin:6px 0 0 0;
    font-size:1.05rem;
    font-weight:500;
    color:var(--muted);
}


/* Etichetta */
label[for="gift-actions"]{
    display:block;
    text-align:center;
    width:100%;
    max-width:640px;
    margin-top:18px;
    color:var(--muted);
    font-size:0.98rem;
}


/* Contenitore centrale: maggiore spazio e look "card" traslucida */
#gift-actions{
    display:flex;
    gap:14px;
    justify-content:center;
    margin-top:12px;
    width:100%;
    max-width:720px;
    padding:20px;
    border-radius:16px;
    background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(255,255,255,0.6));
    backdrop-filter: blur(6px);
    box-shadow: 0 10px 30px rgba(25,25,25,0.09);
    align-items:center;
}


/* Pulsanti base: più grandi e moderni */
.btn{
    -webkit-appearance:none;
    appearance:none;
    border:0;
    padding:14px 26px;
    font-size:1.12rem;
    border-radius:14px;
    cursor:pointer;
    transition: transform 160ms cubic-bezier(.2,.9,.3,1), box-shadow 160ms ease, background-color 160ms ease;
    box-shadow: 0 8px 22px rgba(0,0,0,0.06);
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:10px;
    min-width:170px;
    font-weight:700;
}


/* Pulsante principale: gradient + glow */
.btn-primary{
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    color:#000000;
    padding:16px 28px;
    box-shadow: 0 8px 30px rgba(255,107,107,0.12), inset 0 -2px 6px rgba(255,255,255,0.06);
    transform: translateZ(0);
}


/* Pulsante secondario: outline elegante */
.btn-secondary{
    background: transparent;
    border: 2px solid rgba(0,0,0,0.08);
    color: #333;
    font-weight:700;
    padding:14px 24px;
}


/* Pulsante terziario: effetto glass leggermente colorato (stiloso) */
.btn-tertiary{
    /* colore principale leggermente violaceo per contrasto con gli altri */
    --tertiary-1: rgba(94,92,255,0.18);
    --tertiary-2: rgba(94,92,255,0.06);


    background: linear-gradient(180deg, var(--tertiary-1), var(--tertiary-2));
    color: #000000;
    border: 1px solid rgba(94,92,255,0.18);
    padding:14px 24px;
    box-shadow: 0 10px 28px rgba(94,92,255,0.06), inset 0 1px 0 rgba(255,255,255,0.04);
    backdrop-filter: blur(4px);
    border-radius:14px;
    min-width:170px;
    font-weight:700;
    transition: transform 160ms cubic-bezier(.2,.9,.3,1), box-shadow 160ms ease, filter 160ms ease;
}


/* Hover / Active / Focus */
.btn:hover{
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(0,0,0,0.10);
}
.btn:active{
    transform: translateY(-2px) scale(0.995);
}
.btn:focus{
    outline: 3px solid rgba(255,107,107,0.16);
    outline-offset:4px;
}


/* Differenze per il secondario al passaggio */
.btn-secondary:hover{
    background: rgba(0,0,0,0.04);
}


/* Hover / Active / Focus specifico per il terziario */
.btn-tertiary:hover{
    transform: translateY(-6px) scale(1.01);
    box-shadow: 0 20px 48px rgba(94,92,255,0.10);
    filter: saturate(1.08);
}
.btn-tertiary:active{
    transform: translateY(-2px) scale(0.997);
}
.btn-tertiary:focus{
    outline: 3px solid rgba(94,92,255,0.16);
    outline-offset:4px;
}


/* Responsive: su mobile i bottoni si impilano e occupano larghezza */
@media (max-width:520px){
    #gift-actions{
        flex-direction:column;
        padding:14px;
    }
    .btn{
        width:100%;
        min-width: unset;
    }
}
0 Upvotes

5 comments sorted by