PDA

View Full Version : [HTML CSS]Sovrapporre due div?


codreanu
22-07-2007, 22:12
Ciao programmatori :).

Sto costruendo(ci provo, è il primo) questo sito. Il file è questo:
<html>
<head>
<title>Website</title>
<LINK href="style.css" rel="stylesheet" type="text/css" title="Default Styles" media="screen"/>
</head>
<body>

<div id = "container" align = "center">
<img src="images/website.png" width="900" height="1000" alt="">
</div>

<div id = "article">
<?php
function ReadArticle()
{
$myFile = "Article.txt";
$handle = fopen($myFile, 'r');
$Data = fread($handle, 10);
fclose($handle);
echo $Data;
}
ReadArticle();

?>
</div>

</body>
</html>

Come si vede ho 2 div. Il primo è la base del sito, un'immagine fatta in Photoshop. Il secondo è un pò di testo che la funzione PHP ReadFile() prende da un file .txt.
Vorrei poter sovrapporre i due div in modo che il testo appaia sopra l'immagine fatta in Photoshop. Grazie in anticipo.

Nel .css ho
body {
background-image: url(images/back.jpg);
}

phlebotomus
23-07-2007, 01:22
:)
...il </div> del primo DIV (box) deve andare dopo il </div> del secondo DIV...
Sembra che ho fumato qualcosa di potente...:cool:

PS.
Ovviamente però l'immagine va messa come sfondo del DIV più esterno (come in BODY); oppure la metti come sfondo del DIV col testo ed elimini il DIV esterno...

codreanu
23-07-2007, 03:13
non va. viene cosi
http://img201.imageshack.us/img201/689/immaginely1.th.jpg (http://img201.imageshack.us/my.php?image=immaginely1.jpg)

io il testo voglio metterlo sulla parte bianca. grazie.

phlebotomus
23-07-2007, 12:14
Secondo me, continui a mettere l'immagine non come sfondo ma come immagine normale.
Così funziona già di più:

<html>
<head>
<title>Website</title>
<LINK href="style.css" rel="stylesheet" type="text/css" title="Default Styles" media="screen"/>
</head>
<body>

<div id="container" align="center">


<div id="article">

TESTO O CODICE PHP

</div>
</div>

</body>
</html>

Quindi il CSS è qualcosa tipo:

body {
background-image:url(images/back.jpg)
}
#container {
background-image:url(images/website.jpg);
width:900px;
height:1000px;
margin:auto
}

codreanu
23-07-2007, 12:44
no, mi é sparita l'immagine di background.