L'alignement d'un background (css)

Résolu
Bonjour à tous,

Je rencontre un problème actuellement, j'ai une image que je désires centrer au milieu de ma page web, et qu'elle se situe tout en haut du site et non au centre (c'est une image background).

En ce moment, l'image se situe au centre au niveau Vertical et Horizontal.

Voici mon code :

#cadre_general
{
	width: 1024px;
	height: 768px;
	font-family: Times New Roman;
}

#cadre_back
{
  	height: 1024px;
  	background-image:url(image/background.jpg);
  	background-attachment: fixed;
  	background-position : center;
  	background-repeat: no-repeat;
  	float: top;
}

7 réponses

  1. Problème résolu, on continuant de chercher sur des sites je suis tombé sur le "background-position" que j'utilisais déjà. Mais apparemment on délimite la position vertical et horizontal avec cette balise.

    Donc cela donne :
    #cadre_back
    {
      	background-image:url(image/background.jpg);
      	background-attachment: fixed;
      	background-position : center top;
      	background-repeat: no-repeat;
      	height: 1024px;
    }
    


    Merci beaucoup pour ta patience et tes recherche godLike ;).
    Bonne journée.
    1. Cela ne fonctionne toujours pas :(, je vous envoie le CSS complet :

      #cadre_general
      {
      	width: 1024px;
      	height: 768px;
      	font-family: Times New Roman;
      	color: white;
      }
      
      #Header
      {
        width: 100%;
        height: 30%;
        float: top;
      }
      
      #Gauche
      {
      	width: 20%;
      	height: 70%;
      	margin-top: 0%;
      	text-align: center;
      	float: left;
      }
      
      #cadre_back
      {
        	background-image:url(image/background.jpg);
        	background-attachment: fixed;
        	background-position : center;
        	background-repeat: no-repeat;
        	height: 1024px;
      }
      
      #Content
      {
      	width: 80%;
      	height: 70%;
      	margin-top: 0%;
      	text-align: left;
      	float: right;
      	overflow: auto;
      }
      
      body
      {
          background-color: #000000;
      }
      


      L'ordre des <div> dans les pages web sont :
      - body
      - cadre_back
      - cadre_general
      - Header
      - Gauche
      - Content

      Voila en espérant que ça ai pu vous aider :)
      1. Au temps pour moi , en fait c'est :

        align="top" qui est à mettre dans un <div></div>, donc essaie de faire un <div></div> pour ton en-tête avec align="top" dedans, du genre :

        <div id="header" align="top">
        ----------------------------------
        ----------------------------------
        </div>

        Et dans ton CSS tu entre les propriétés de ton div

        #header{
        -----
        -----
        }

        Voilà :) en espérant que ca marche.
        1. Non toujours pas,

          align: top;

          N'est apparemment pas une balise correcte...
          1. Essaye de mettre :

            align:top;

            dans les propriétés CSS du body .
            1. Il ne faut pas la mettre dans un <div></div>

              Fait plutôt ça :

              body
              {
                	height: 1024px;
                	background-image:url(image/background.jpg);
                	background-attachment: fixed;
                	background-position : center;
                	background-repeat: no-repeat;
                	float: top;
              }
              


              Voilà , bonne journée.