1

Quand je mets ce qui suit dans un div dans le body principal, cela fonctionne:CSS Fail - background-position, répétition de fond, taille de fond, background-attachment

<div style="display: block; width:100%; height: 100%; min-height: 100vh; background-color: #FFFFFF; background: url(./images/pic.jpg); background-position: center; background-repeat: no-repeat; background-size: cover; background-attachment: fixed;"> 

mais quand j'utilise CSS est NE FONCTIONNE PAS:

<style type="text/css" media="all"> 
.myMainDiv { 
    width:100%; 
    height: 100%; 
    min-height: 100vh; 
    background-color: #FFFFFF; 
    background-position: center; 
    background-repeat: no-repeat; 
    background-size: cover; 
    background-attachment: fixed; 
} 
</style> 

<div class="myMainDiv" style="display: block; background: url(./images/pic.jpg);"> 

Il semble aller mal, parce que je besoin d'un autre pic pour chaque fond et cela se traduit dans le background-repeat etc être ignoré. (Remarque: des divs différents auront des valeurs d'affichage différentes, qu'elles soient en bloc ou non, elles doivent donc être indiquées séparément, mais ce n'est pas le problème.)

Quelqu'un sait pourquoi et s'il existe une solution de contournement.

+0

avez-vous inclus '.myMainDiv {...}' entre ''? – Banzay

+0

Le placez-vous à l'intérieur de l'étiquette