Page 1 sur 2

[CSS] du texte sur une image

Posté : 12 nov. 2006, 17:35
par katagoto
Bonjour a tous et toutes,
Voilà je suis nul en CSS, et j'aimerai savoir comment faire pour mettre des liens et des texte sur une image

Ma page CSS :
p
{
color:white
}
body
{
background-image: url("imgfont.jpg");
background-attachment: fixed;
background-repeat: no repeat; 
width: 760px;
margin: auto; 
margin-top: 20px; 
margin-bottom: 20px;    
}

/* Le menu */

#menu
{
float: left; 
width: 120px; 
color: red;
background-color: white
}

.element_menu
{
border: 2px solid white;
margin-bottom: 20px; 
background-color:red;
}

.element_menu h3 
{    
font-family: "Comic Sans Ms", "Arial Black" , serif;
text-align: center;
}

.element_menu ul 
{
list-style-image: url("puce.png");
padding: 0px;
padding-left: 20px; 
margin: 0px; 
margin-bottom: 5px; 
}

.element_menu a
{
text-decoration:none;
color:white
}

.element_menu a:hover
{
text-decoration:underline
}

.element_menu a:active,.element_menu a:focus
{
background-color:rgb (120,200,226)
}

/* Le corps de la page */

#corps
{
margin-left: 140px; 
margin-bottom: 20px; 
padding: 5px; 
color: ;
background-color:black  ; 
background-image: url("");
background-repeat: repeat-x; 
border: 2px solid white; 
}

#corps h1 
{
text-align:center ;
font-family: "Comic Sans Ms","Arial Black";
border-bottom:2px solid white;
padding:5px;
color:white
}

#corps h2 
{
height: 30px;
background-image: url(""); 
background-repeat: no-repeat; 
padding-left: 30px;
color: ;
text-align: center;
border-bottom: 1px solid white;
border-top: 1px solid white;
color:white
}
#corps .sign
{
text-decoration:underline;
}
#corps .art
{
color: rgb(237,173,116);
font-weight:bold;
text-decoration:underline;
}

#corps p:first-letter
{
float:left; 
font-size:3em; 
font-family:"Comic Sans Ms","Arial Black", serif; 
font-weight:bold; 
}

#corps form, .pages
{
text-align:center;
}

img
{
font-size:medium;
}
J'ai un peu commencé mais ça se place pas, pouvez-vous m'aidé...

D'avance merci

Posté : 12 nov. 2006, 18:37
par albat
il te suffit de passer l'image en background.

Le style CSS :
div { background-image:url(machin.png) ; background-repeat:no-repeat }
Le code XHTML :
<div>
    <p>Voici mon texte qui s'affiche sur l'image souhaitée<br />
       et qui peut aussi contenir <a href="#">un lien<a><br />
       ou une autre <img src="image.png" alt="image" />.</p>
</div>

Posté : 12 nov. 2006, 19:08
par katagoto
ok, merci j'ai oublié de préciser le menu et le texte doivent être à deux endrois précis et distinc, esce encore possible...

D'avance merci

Posté : 12 nov. 2006, 19:15
par albat
À priori, oui.
Les CSS te permettent de positionner avec précision chacun de tes éléments.

Posté : 13 nov. 2006, 19:06
par katagoto
Ok merci mais, pouvez-vous, s'il vous plait m'expliqué comment ou en me fillant le code, là je suis largué en CSS ^^'

D'avance merci

Posté : 13 nov. 2006, 19:20
par Cyrano
Tiens, regarde un peu par ICI

Posté : 14 nov. 2006, 21:50
par katagoto
Bonsoir je doit vraiment être un novice voilà j'ai une image (1 000*750) et j'aimerai placer un menu (100*200) à 50px de la gauche et à 125px du haut, esce possible ??? Je sais que j'en demande beaucoup mais je comprend quasiment rien au CSS :oops:

Posté : 14 nov. 2006, 21:54
par Cyrano
As-tu suivi le lien que j'ai mis plus haut ???

Posté : 15 nov. 2006, 08:25
par katagoto
Bah ouui mais ça me fais une amige diforme ou incomplête, j'y comprend plus rien :roll: :shock: :x Je vais tenter quelques choses, mais bon...

Posté : 15 nov. 2006, 09:08
par Cyrano
Mets nous donc les extraits correspondant du code que tu as écrit qu'on sache d'où on part. Et si tu as un lien vers une page en ligne, ce sera encore mieux.

Posté : 15 nov. 2006, 12:34
par fred9999
salut
si tu veut comprendre facilement le css
va la sinon http://mammouthland.free.fr/cours/css/index.php

Posté : 15 nov. 2006, 13:23
par albat
Bah ouui mais ça me fais une amige diforme
En effet, c'est difforme ! :roll:

Posté : 15 nov. 2006, 14:05
par Cyrano
...là je suis largué en CSS...
Et le lien que tu nous mets est un site qui semble avoir pour vocation de montrer comment utiliser les CSS. On croît rêver là :-k

Posté : 15 nov. 2006, 14:59
par katagoto
Mon code :
p
{
color:black
}
body
{
background-image: url("");
background-attachment: fixed;
background-repeat: no repeat; 
width: 806px;
margin: auto; 
margin-top: 20px; 
margin-bottom: 20px;    
}

/* Le menu */

#menu
{
float: left; 
width: 120px; 
color: ;
background-color: ;
}

.element_menu
{
border: 2px solid white;
margin-bottom: 20px; 
background-color:red;
}

.element_menu a
{
text-decoration:none;
color:white
}

.element_menu a:hover
{
text-decoration:underline
}

.element_menu a:active,.element_menu a:focus
{
background-color:rgb (120,200,226)
}

/* Le corps de la page */

#corps
{
padding-top: 100px;
padding-left: 127px;
padding: 5px; 
color: ;
background-color: ; 
background-image: url("PLANCHE.PNG");
background-repeat: repeat-x; 
border: 50px solid white; 
}

.bloc {
  width: 206px; /*155*/
  height: 127px; /*375*/
  background-color:;
}
Lien :http://knightoffear.free.fr/phpforever/page.html

Voilà là on voit bien le bug ;)

D'avance merci de vis aides :idea:

Posté : 15 nov. 2006, 15:34
par Cyrano
Mouais, si on veut, ou plutôt on ne voir pas ce qui devrait apparaitre.
Si tu commençais pas du code HTML conforme, ce serait déjà un progrès. Ta balise <body> n'est pas ouverte et tu as une balise de fermeture </form> qui ne correspond à rien.

Ensuite, le problème tient aux positionnements. Tu as mis le menu en position flottante, mais pas en position absolue alors que le design d'arrière-plan a des dimensions précises.

Proposition globale :
-1- le HTML :

Code : Tout sélectionner

<?xml version="1.0" encoding="iso-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" > <head> <title>==> titre <==</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" media="screen" type="text/css" title="style.css" href="style.css" /> </head> <body> <div id="corps"> <div id="menu"> <div class="element_menu"> <p><a href="#corps">lien 01</a></p> <p><a href="#corps">lien 02</a></p> </div> </div> <div id="contenu"> <p>texte...</p> </div> </div> </body> </html>
-2- le style CSS :

Code : Tout sélectionner

body { width: 806px; margin: auto; margin-top: 20px; margin-bottom: 20px; } p { color:black } /* Le corps de la page */ #corps { position: relative; padding-top: 100px; padding-left: 127px; padding: 5px; color: ; background-color: ; background-image: url("./PLANCHE.PNG"); background-repeat: repeat-x; border: 50px solid white; height: 695px; border: none; } .bloc { width: 206px; /*155*/ height: 127px; /*375*/ background-color:; } /* Le menu */ #menu { position: absolute; top: 220px; left: 145px; width: 120px; color: ; background-color: ; } .element_menu { border: 2px solid white; margin-bottom: 20px; background-color:red; } .element_menu a { text-decoration:none; color:white } .element_menu a:hover { text-decoration:underline } .element_menu a:active,.element_menu a:focus { background-color:rgb (120,200,226) } /* Le contenu */ #contenu { position: absolute; top: 190px; left: 340px; }
Tu noteras que j'ai ajouté un bloc pour le texte de la partie principale pour pouvoir le positionner. J'ai également modifié l'ordre dans la feuille de style. On part du plus haut niveau jusqu'au points de détail, jamais l'inverse. Alors là c'est rapide, j'ai pas fouillé les détails.