Jump to content

why does my div move when i use a foreach loop ?


ricky spires

Recommended Posts

hello

 

why does my div move when i use a foreach loop ?

 

if i use the code below i get the following

 

i added a border style to the div so i can see that some are in and some are out:

 

result 1 = not in a div

result 2 = in a div

result 3 = in a div

etc

then on the end i get a div with no result in it

 

 

function  name(){

echo'
<div id="divName">';

   $a = Class::find_all(); 

   foreach ($a as $ab){
   $name = $ab->name;
   $dest = $ab->destination;

   <ul>
   <li><a href="index.php?pageID='.$dest.'">'.$name.'</a></li>
   </ul>';
   }

echo'</div>';	
}

 

thanks

rick

Maybe you're using position: relative; left: (number)px; ?

I know that happened to me when I used position: relative while looping divs.

 

If you are, then try not to position those divs by relative or absolute position, but by static.

 

If that was not the problem, then I don't know what the problem is. Maybe post the full code?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.