Visualizzazione dei risultati da 1 a 8 su 8
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2009
    Messaggi
    33

    DIV con scrollbar e sfondo fermo

    Ciao a tutti,
    vi espongo subito il mio problema:

    Ho un div ad altezza fissa, ho delle scritte ed uno sfondo e una scrollbar.

    Vorrei che, se l'utente muove la scrollbar, lo sfondo rimanga fisso.

    Di default funziona senza aggiungere niente con firefox, IE8, Google Chrome aggiornato.

    Invece con IE7 non funziona.

    Leggendo in rete sentivo di gente che aggiungeva un:
    Codice PHP:
        background-attachmentfixex
    nel CSS.

    Facendo così però lo sfondo si sposta in alto.

    Sapete aiutarmi?

    Vi posto il CSS del div interessato:

    Codice PHP:
    #centro {
        
    positionabsolute;
        
    top250px;
        
    left:50%;
        
    margin-left: -420px;
        
    width:860px;
        
    height400px;
        
    overflowauto;
        
    background-imageurl(immagini/sfondo_riquadro.png);
        
    background-position0 0;
        
    background-repeatno-repeat;
        
    text-align:center;


  2. #2
    Utente di HTML.it L'avatar di emnlmn
    Registrato dal
    Oct 2008
    Messaggi
    263
    cosa intendi con "lo sfondo si sposta in alto" ?
    quale dovrebbe essere la sua posizione?

  3. #3
    Utente di HTML.it
    Registrato dal
    Mar 2009
    Messaggi
    33
    scusa, allora ho un div con lo sfondo.

    Il div è a TOP:200, se metto il background:fixed; lo sfondo non comincia da 200 ma da 0.

  4. #4
    Utente di HTML.it
    Registrato dal
    Mar 2009
    Messaggi
    33
    sto diventando pazzo.
    Con le versioni non aggiornate di chrome dava lo stesso problema.

  5. #5
    Utente di HTML.it
    Registrato dal
    Mar 2009
    Messaggi
    33
    provo con un UP!

  6. #6
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    21,188
    Prova a vedere se questo, pubblicato oggi, puo` servire anche nel tuo caso.
    Position fixed performante su IE6
    Nuova politica di maggiore severita` sui titoli delle discussioni: (ri)leggete il regolamento
    No domande tecniche in messaggi privati

  7. #7
    Ho provato a fare così e da me funziona (Firefox)

    prova.html
    codice:
    <html>
    
    <head>
    <title>Prova CSS</title>
    
    <link rel="stylesheet" type="text/css" href="style.css">
    
    </head>
    
    <body>
    
    <div id="centro">
    	<div class="background"></div>
    	<div style="font-weight: bold;">Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    	Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
    	when an unknown printer took a galley of type and scrambled it to make a type
    	specimen book. It has survived not only five centuries, but also the leap into
    	electronic typesetting, remaining essentially unchanged. It was popularised in
    	the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
    	and more recently with desktop publishing software like Aldus PageMaker including
    	versions of Lorem Ipsum.
    	
    	Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    	Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
    	when an unknown printer took a galley of type and scrambled it to make a type
    	specimen book. It has survived not only five centuries, but also the leap into
    	electronic typesetting, remaining essentially unchanged. It was popularised in
    	the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
    	and more recently with desktop publishing software like Aldus PageMaker including
    	versions of Lorem Ipsum.</div>
    </div>
    
    </body>
    
    </html>
    style.css
    codice:
    #centro {
    	height: 300px;
    	width: 500px;
    	overflow: scroll;
    }
    
    .background {
    	background-image: url("background.gif");
    	background-position: 0 0;
    	background-repeat: no-repeat;
    	position: absolute; 
    	height: 100%;
    	width: 100%;
    	z-index: -1;
    }
    Quello che ho pensato di fare è stato quello di creare un contenitore apposta solo per il background che, grazie a "position: absolute" lo ferma anche se il div scrolla.

    Dimmi se funziona correttamente su altri browser

  8. #8
    Utente di HTML.it
    Registrato dal
    Mar 2009
    Messaggi
    33
    Originariamente inviato da Mich_
    Prova a vedere se questo, pubblicato oggi, puo` servire anche nel tuo caso.
    Position fixed performante su IE6
    Non è quello che serve a me visto che a me serve la compatibilità con IE7.
    Originariamente inviato da Nophiq
    Ho provato a fare così e da me funziona (Firefox)

    prova.html
    codice:
    <html>
    
    <head>
    <title>Prova CSS</title>
    
    <link rel="stylesheet" type="text/css" href="style.css">
    
    </head>
    
    <body>
    
    <div id="centro">
    	<div class="background"></div>
    	<div style="font-weight: bold;">Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    	Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
    	when an unknown printer took a galley of type and scrambled it to make a type
    	specimen book. It has survived not only five centuries, but also the leap into
    	electronic typesetting, remaining essentially unchanged. It was popularised in
    	the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
    	and more recently with desktop publishing software like Aldus PageMaker including
    	versions of Lorem Ipsum.
    	
    	Lorem Ipsum is simply dummy text of the printing and typesetting industry.
    	Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
    	when an unknown printer took a galley of type and scrambled it to make a type
    	specimen book. It has survived not only five centuries, but also the leap into
    	electronic typesetting, remaining essentially unchanged. It was popularised in
    	the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
    	and more recently with desktop publishing software like Aldus PageMaker including
    	versions of Lorem Ipsum.</div>
    </div>
    
    </body>
    
    </html>
    style.css
    codice:
    #centro {
    	height: 300px;
    	width: 500px;
    	overflow: scroll;
    }
    
    .background {
    	background-image: url("background.gif");
    	background-position: 0 0;
    	background-repeat: no-repeat;
    	position: absolute; 
    	height: 100%;
    	width: 100%;
    	z-index: -1;
    }
    Quello che ho pensato di fare è stato quello di creare un contenitore apposta solo per il background che, grazie a "position: absolute" lo ferma anche se il div scrolla.

    Dimmi se funziona correttamente su altri browser
    A me con firefox non funziona.
    Con IE incasina tutto alla grande.

    (www.weddinginthelanga.com/never.html)

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.