Forum Moderators: not2easy

Message Too Old, No Replies

relative position problems

         

charlee

8:16 pm on Jun 20, 2008 (gmt 0)

10+ Year Member



ive spent two hours trying to figure out how to place a description text along the side of a picture using relative positioning and it works perfectly until i duplicate the code. Id like to have one picture and the description and then other one under with its correspondant description.

the first instance of the code works good, but the second pushes the picture to the right when its supposed to stay in the left side.

the best i could do was putting a <br clear="all"/> after the first description but this is not good cause since the position of the data is relative and moved by bottom and left properties then the space where this data was located before moving it, its being reserved, resulting in an a big empty gray space. I dont know what else to do, i gave up guys, I will really apreciate any helps or tips about relative positioning.

THANKS IN ADVANCE :)

here is the XHTML

<div id="fighters">
<div class="descriptionBar"><p><b>FEATURED FIGHTERS</b></p></div>
<p class="fightersInfo">
<img src="images/Figther001.jpg" alt="figther1" />
<span class="fighterData">
<br />
BLAS AVENA<br />
Height 5'3"<br />
Weight 135 lbs<br />
Record 135 lbs<br />
</span>
</p>
<p class="fightersInfo">
<img src="images/Figther001.jpg" alt="figther1" />
<span class="fighterData">
<br />
BLAS AVENA<br />
Height 5'3"<br />
Weight 135 lbs<br />
Record 135 lbs<br />
</span>
</p>
<!--end #fighters--></div>

HERE IS THE CSS

.common #fighters {
position: relative;
width: 310px;
left: 0px;
float: right;
background-color: #333333;
}
.fightersInfo {
background-color: #414141;
padding: 10px;
margin: 10px 0px 10px 0px;
}
.fighterData {
width: 200px;
font-weight: bold;
position: relative;
float: left;
left: 100px;
bottom: 120px;
}

.fightersInfo img {
border: 1px solid #999999;
position: relative;
}

D_Blackwell

9:34 pm on Jun 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As no one has taken a shot at this, I though I'd play with it a tad. I am not certain as to exactly what you are trying to accomplish, so have used some considerable discretion in reworking. It may not be at all what you want. As I understand the the question, Id like to have one picture and the description and then other one under with its correspondant description., you are not looking to 'float: left;' one after another across the screen, but want the images presented as 'stacked boxes' with one picture and description below the previous.?

The following rework stacks the images, and fixes but the second pushes the picture to the right when its supposed to stay in the left side. and maintains place a description text along the side of a picture

This works in varying versions of FF, Opera, and IE - but may not be at all what you want. Had to guess a bit. It's appropriateness depends upon what you want to do with the rest of the right-hand side of the page. You are almost certainly going to have to adjust or, more likely, add <div>s to complete a workable page. In the meantime, the 'image and caption and stacking solution might give you a place to start.

<html>
<head>
<style>
.img-block {
background-color: #414141; position: relative; width: 300px; height: 300px; margin-top: 1em;
}
.img-block .img-box {

}
.img-block .img-box img {
width: 250px; height: 250px; margin-top: 25px; margin-left: 25px;
}
.img-block .img-box span {
position: absolute; right: 30px; bottom: 30px; color: #000; background-color: #faebd7; padding: 5px;
}
</style>
</head>
<body>
<!--
ive spent two hours trying to figure out how to place a description text along the side of a picture using relative positioning and

it works perfectly until i duplicate the code. Id like to have one picture and the description and then other one under with its orrespondant description.

the first instance of the code works good, but the second pushes the picture to the right when its supposed to stay in the left side.

the best i could do was putting a <br clear="all"/> after the first description but this is not good cause since the position of the

data is relative and moved by bottom and left properties then the space where this data was located before moving it, its being reserved, resulting in an a big empty gray space. I dont know what else to do, i gave up guys, I will really apreciate any helps or tips about relative positioning.
-->

<div class="img-block">
<div class="img-box">
<p>
<img src="aaa.jpg" />
</p>
</div>
</div>

<div class="img-block">
<div class="img-box">
<p>
<img src="aaa.jpg" />
<span>
BLAS AVENA<br />
Height 5'3"<br />
Weight 135 lbs<br />
Record 135 lbs<br />
</span>
</p>
</div>
</div>

<div class="img-block">
<div class="img-box">
<p>
<img src="aaa.jpg" />
<span class="fighterData">
BLAS AVENA<br />
Height 5'3"<br />
Weight 135 lbs<br />
Record 135 lbs<br />
</span>
</p>
</div>
</div>
</body>
</html>

<edit - text clarification>

[edited by: D_Blackwell at 9:37 pm (utc) on June 22, 2008]

charlee

5:13 pm on Jun 24, 2008 (gmt 0)

10+ Year Member



I tried your code and it didnt work, it was really a mess in my template, dont know what im doing wrong here. But summarizing my problem, as you can see in my code the div fighter is the container of this section. What i want to achieve is just have an image at the left with a text at the right. Thats it, and it works perfectly if i didnt have to repeat the same thing again, cause when i try to put a second instance of the same code then this second instance pushes the image to the right, but still the first instance remains perfectly fine. Im not allowed to post links here so I will have to ask for specific things. At least Id like to know why if the position for a divission is relative and i move it using top and left or right and bottom, still the space this div was occupaying before moving it remains untouched as if the div were here when it actually is not.

thanks in advance.

charlee

5:41 pm on Jun 24, 2008 (gmt 0)

10+ Year Member



ok i finally got it, reading other post in this forum, i had to place the position relative for fightersInfo and absolute for fighterData and it works great, in every single modern browser out there :)