Forum Moderators: not2easy

Message Too Old, No Replies

background and text in the div

         

uavide

6:13 pm on Jun 21, 2009 (gmt 0)

10+ Year Member



Good evening, i'm sorry for my english.
I have a problem.

I have a background and some div with the text inside over the background.

The problem is that when i try to resize the browser, the background follow the size of it, but the div they don't follow the background, so i want that in any case of resolution, the div must be fixed in the position where i want.

How i can do?

Thanks

Bye

holyhttp

5:03 pm on Jun 23, 2009 (gmt 0)

10+ Year Member



You can use absolute positioning or fixed positioning to place your div where you want it to be.

#mydiv{
position: absolute;
top:20px; /* put the proper value */
left:5px; /* put the proper value */
}

or
#mydiv{
position: fixed;
top:20px; /* put the proper value */
left:5px; /* put the proper value */
}

Rename #mydiv however you want to name it as an ID or class.

uavide

6:57 pm on Jun 24, 2009 (gmt 0)

10+ Year Member



Thanks for the answer, my problem it's a bit strange.
here: <snip>

here my body of css

{
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
border: 0;
background: url(media/intro3.jpg);
background-repeat:no-repeat;
background-position:top;
background-color:#481212;
font-size: 10px;
font-family:Arial, Verdana, Helvetica, sans-serif;
text-decoration:none;
color:#FFFFFF;
}

and the div:

.container {
PADDING-BOTTOM: 3px;
MARGIN: 0px auto;
WIDTH: 400px;
TEXT-ALIGN: left;
padding-top:10PX;
padding-left:10PX;
position:absolute;
}

.container2 {
PADDING-BOTTOM: 3px;
MARGIN: 0px auto;
WIDTH: 400px;
TEXT-ALIGN: RIGHT;
padding-top:10PX;
padding-right:20PX;
position:absolute;
}

this the html for the div:

<div id="container" style=" width:400px; height:190px; margin-left:195px; margin-top:500px;"><span class="Titolo_offerte">RISTORANTE <BR /><BR /><BR />
</span>
Visita il nostro Ristorante con terrazza direttamente affaciata sul "Lago di Como" con la possibilità di cenare al tramonto, ci trovate a Tremezzo,<span class="Testo">Situato a 100m dalla famosa &quot;Villa Carlotta&quot;, di fronte a Bellagio...</span></div>
<div class="id" style=" width:400px; height:20px; margin-left:195px; margin-top:-100px;"><span class=" vai" style="text-align:right"><strong><a href="rist/home.php" class="vai">VAI AL RISTORANTE</a> <span id="vai_frecce">»</span></strong></span></div>

The problem it's that my background it's on the center but my div if i resize the windows browser or if i change the resolution they don't stay always in the same place where i want, but the move over the background...
how i can do?

Thanks

Bye

[edited by: swa66 at 7:41 pm (utc) on June 24, 2009]
[edit reason] No personal URLs please see ToS and forum charter [/edit]