Page 1 of 1
Noob question about aligning divs in PHp
Posted: Sat Nov 23, 2013 4:37 am
by Xaos
So, I have this code
Code: Select all
for($i=0;$i <= $stock; $i++){ //creates a loop that checks versus stock
if($i % 25 == 0){ //break every 25 Fs
echo "</br>";
}
echo "F"; //echo F to symbolize number of fish, will be reproduced by graphic so
}
and I want to put all of the Fs (which will be graphics eventually)on one side of the page, so logically they need to be put into a div and be manipulated with CSS. But the question is....how do I make this happen? Thanks guys

Re: Noob question about aligning divs in PHp
Posted: Sat Nov 23, 2013 8:20 am
by Gunner
Just make it like this
Code: Select all
echo "<div align='center'>" . "F" . "</div>"
Or did I get your question wrong?
Re: Noob question about aligning divs in PHp
Posted: Sat Nov 23, 2013 3:33 pm
by Xaos
Gunner wrote:Just make it like this
Code: Select all
echo "<div align='center'>" . "F" . "</div>"
Or did I get your question wrong?
Duh, now I feel dumb

But now that I did that, all of the fish are lining up in a line, like so
http://gyazo.com/d9630c4b67ec38f48b9f2e415cff7f81 when they should really be in blocks, like so
http://gyazo.com/6b646e0d5aea2227bf9332ec39d2222e
Also, how would I get them in-line wth the text? IE the block of fish starting at the top of the page on the right? Do I just use CSS? How do I call the CSS in PHP, just include orrr?
Re: Noob question about aligning divs in PHp
Posted: Sat Nov 23, 2013 4:34 pm
by Script47
Xaos wrote:Gunner wrote:Just make it like this
Code: Select all
echo "<div align='center'>" . "F" . "</div>"
Or did I get your question wrong?
Duh, now I feel dumb

But now that I did that, all of the fish are lining up in a line, like so
http://gyazo.com/d9630c4b67ec38f48b9f2e415cff7f81 when they should really be in blocks, like so
http://gyazo.com/6b646e0d5aea2227bf9332ec39d2222e
Also, how would I get them in-line wth the text? IE the block of fish starting at the top of the page on the right? Do I just use CSS? How do I call the CSS in PHP, just include orrr?
Put a line break after the "F" like so:
Code: Select all
echo "<div align='center'>" . "F<br/>" . "</div>"
It may work I'm not sure.

Re: Noob question about aligning divs in PHp
Posted: Sun Nov 24, 2013 12:50 am
by Xaos
I put the stuff in divs and tried to use a CSS, but it made it so it pushed it all the way to the right of the page and only showed 1 fish per row, all lined up in a column, like this:
Text X
X
when it should be like
Text XXXXXXX
and etc.
Re: Noob question about aligning divs in PHp
Posted: Sun Nov 24, 2013 3:43 am
by mahks
Code: Select all
for($i=0;$i <= $stock; $i++){ //creates a loop that checks versus stock
echo '<div class="fish_pic '
.(($i % 25 == 0)? 'fish_brk':'')
.'"></div>';
}
CSS:
.fish_pic{float:left;background:url(url_to_fish)}
.fish_brk{clear:left}
Re: Noob question about aligning divs in PHp
Posted: Sun Nov 24, 2013 4:06 am
by Xaos
Re: Noob question about aligning divs in PHp
Posted: Sun Nov 24, 2013 4:20 am
by MikuzA
Code: Select all
<style>
div {display:inline}
</style>
<div>Fish</div>
<div>Fish</div>
<div>Fish</div>
This you looking for?

Re: Noob question about aligning divs in PHp
Posted: Sun Nov 24, 2013 4:22 am
by mahks
Re: Noob question about aligning divs in PHp
Posted: Sun Nov 24, 2013 4:26 am
by Xaos
I have this:
Code: Select all
for($i=0;$i <= ($stock/5); $i++){
if($i % 45 == 0){
echo '<div class="fish_brk">';
echo "</br></div>";
}
echo '<div class ="fish_pic">';
echo '<img src = "smallfish.png"></div>';
}
in the PHP file and
Code: Select all
.fish_pic{
float:right;
background:url(url_to_fish)
}
.fish_brk{
clear:right
}
for the CSS.