Forum Moderators: not2easy

Message Too Old, No Replies

Problem with positioning elements

         

noukheet

11:05 am on Mar 30, 2011 (gmt 0)

10+ Year Member



Hi, i am haveing some problems with positioning elements with css.

Okay so heres the problem, i am not a good with css/html but i am working in IT industry and i have experince from java and c++. My friends company wanted new web site and they hired a designer to design it and they had a programmer also for html/css but he canceled and they asked me to do it, so i tought that how hard it could be since i have some experince from html / css and java + and c++ experince? well if i had known how many issues i would have, i would have said no.

Okay now to the problems, i used absolute positioning for the elements, first i did it with % like this:

From html:
<div class="viiva1">
<img src="images/palikat/viiva5.jpg">
</div>

From css:
.viiva1 {
top: 50%;
left: 20%;
position: absolute;
}

Okay, now i got everything positioned very nicely but then i noticed that i am haveing major issues when resesizing browser elements would overlap each others and the layout changes when useing diffrent size monitor.

Then i tought that mayby if i change % to px it would look as same on every screen

new css code:

.viiva1 {

top: 500px;
left: 520px;

position: absolute;
}

Okay, now everything is fine when i look at the page with normal computer screen but with laptop and small screen the page look terrible.

I have read about liquvid layout but i dont understand how i should place the elements so it would look same with every screen / browser and what are the commands for that? The big problem is that i need to do exatly same looking page as the designer has done, so i have no clue how i can place like thise yellow lines in exact position without useing position command?

Also other big problem is with css table i have done, the table looks nice and i have divided that table to 3 columns but i would want to make that last 3 colum smaller than other two, becose in the first 2 colums there is text but the last colum is for number so it look kinda stupid when it so big. And this is not even the biggest problem, the big problem is again when resizing the browser, i have added 2 yellow lines that are jpg that go trough the table, again when i resize the browser the table text moves but ofcourse the lines stay at their place, so it looks really stupid when my lines.jpg goes over the table text

I hope that someone can help me here and tell me what i am doing wrong, Thank you!

birdbrain

1:54 pm on Mar 30, 2011 (gmt 0)



Hi there noukheet,

and a warm welcome to these forums. ;)

With the minimal code that you have supplied, it is difficult to know your exact requirements. :(

I would however suggest that, in the main, absolute positioning is absolutely unnecessary. ;)

This example will make the image display uniformly for various screen resolutions...


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">

<title>untitled document</title>

<style type="text/css">
.viiva1 img {
display:block;
margin:auto;
}
</style>

</head>
<body>

<div class="viiva1">
<img src="images/palikat/viiva5.jpg" alt="viiva5"><!--added the required alt attribute -->
</div>

</body>
</html>

birdbrain

noukheet

4:45 pm on Mar 30, 2011 (gmt 0)

10+ Year Member



birdbrain, Thank you from you replay, i would post the url of the web page but it seems to be forbidden, i have problem of understanding how i can add image to exact position without useing position function. Someone told me to use floats with margins but i am haveing problems of understanding how that works in action.

The designer has designed the web page and i need to make exact copy of it, it has many images and stuff what i need to position in exact same positions as he has designed.


I can copy part of css code and html code:

CSS:

.r_logo {

top: 150px;
left: 680px;
position: absolute;

}

.kaupunki {
font-family:"Arial";
font-size:20px;
color: white;
font-weight:bold;
top: 385px;
left: 380px;
position: absolute;
}

.kuvat {

top: 425px;
left: 385px;
position: absolute;

}


.viiva {
top: 690px;
left: 385px;
position: absolute;
}

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link rel="StyleSheet" href="css/reis.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
<link rel="StyleSheet" href="css/yhteinen.css" type="text/css" media="screen" />


<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>


<title>Korson Sahko-Yksikko Oy</title>
</head>
<body BGCOLOR="black">
<div style="overflow: auto;">

div class="teksti">
HENKILÖKUNNAN<BR>VIRKISTÄYTYMINEN
</div>

<div class="r_logo">
<IMG SRC ="images/palikat/reissu_logo.jpg">
</div>

<div class="kaupunki">
Työntekijöiden 10v juhlat casinolla
</div>

<div class="kuvat">
<a href="images/10v/1.jpg" rel="lightbox[casino]" title="Show & dinner"><IMG SRC ="images/10v/t1.jpg" border="0"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="images/10v/2.jpg" rel="lightbox[casino]" title="Show & dinner"><IMG SRC ="images/10v/t2.jpg" border="0"></a>

</div>

<div class="viiva">
<IMG SRC ="images/palikat/reissu_viiva.jpg">
</div>

</body>
</html>


The problem is clearly in useing position absolute what gets me in trouble here, so if someone could please give me somekinda hint how to do this with floats and margins or whatever makes it work and look nice and same on all browsers and monitors.

About the code: there is only part of the code what i copyed, if you need the hole code i can paste it ofcourse, but i think you understand the problem from that

Thank you!