View Full Version : include and css
ggalan
06-10-2010, 02:21 PM
when i use:
<?php include("Menu.php");?>
the div underneath it does not get pushed down after the div inside Menu.php is included. is there a trick to this so that i DONT have to use absolute positioning for all the content that is not included?
bluewalrus
06-10-2010, 02:51 PM
This tells us nothing of the coding the include just brings the code in that page into the page you are on.
For example say you have index.php and menu.php.
index.php
<div id="simple">
This is an example.
<div id="content">
<div id="menu">
<?php include("menu.php")?>
</div>
Page stuff
</div>
</div>
menu.php
<ul>
<li>Home</li>
<li>Photos</li>
<li>Links</li>
</ul>
That is as the code would be on your server but when the page gets loaded it becomes
<div id="simple">
This is an example.
<div id="content">
<div id="menu">
<ul>
<li>Home</li>
<li>Photos</li>
<li>Links</li>
</ul>
</div>
Page stuff
</div>
</div>
The ul then gets the css properties of the 3 divs above and the attributes set for ul and lis.
ggalan
06-10-2010, 03:02 PM
thank you for the response
so then if "page stuff" had a relative position then it wouldnt move down after menu.php got in there. in other words if i dont set position:relative; top:50px; the menu.php will overlap "page stuff"
(the css above is just a hypothetical setting)
bluewalrus
06-10-2010, 05:18 PM
Not sure off the top of my head. Is the site live, could you provide a link, or provide the css you are using so I may adjust my sample?
Beverleyh
06-10-2010, 06:19 PM
What if you try putting a cleared break below the menu div ?
<br style="clear:left"/>
(also try "clear:right" or "clear:both" depending on the other div float alignments on the page)
ggalan
06-10-2010, 06:37 PM
started to make a sample and now it works. seems like as long as i dont add
// or any other position setting
position: relative;
things stack up according to order
djr33
06-10-2010, 07:15 PM
As has been said above, post a link to the page if you need help with it.
php includes aren't special: they are a simple process taking the text from one file and inserting it into another. The only thing that matters for CSS/design issues is to look at the generated source code (the easiest way is to use view>source) and work it out from there. It will be an extra step then to get the includes to fit in well enough with the rest of it, but once you know your goal (desired output) it should be easy.
The "include" process is demonstrated well in bluewalrus's first reply.
ggalan
06-11-2010, 04:48 PM
can i ask why you didnt put div inside the menu.php file in bluewalrus's first reply.
lke, menu.php:
<div id="menu">
<ul>
<li>Home</li>
<li>Photos</li>
<li>Links</li>
</ul>
</div>
djr33
06-11-2010, 06:51 PM
It's completely irrelevant where the code is located, just how it goes together. Originally in one file or the other, the text will still create the same output.
However, I can see the reason you'd want to put it in there, and that's fine.
On the other hand, keeping it in the main file makes some sense too, as a placeholder for the content it's going to grab later.
In other words, do whatever you'd like with organization and make it easier on yourself, just make sure the generated output is correct and then it's fine.
ggalan
06-11-2010, 07:37 PM
cool, thank you
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.