Results 1 to 10 of 10

Thread: include and css

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default include and css

    when i use:
    Code:
    <?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?

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    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

    PHP Code:
    <div id="simple">
    This is an example.
    <div id="content">
    <div id="menu">
    <?php include("menu.php")?>
    </div>
    Page stuff
    </div>
    </div>
    menu.php

    PHP Code:
    <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

    Code:
    <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.
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    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)

  4. #4
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    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?
    Corrections to my coding/thoughts welcome.

  5. #5
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    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)

  6. #6
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    started to make a sample and now it works. seems like as long as i dont add
    Code:
    // or any other position setting
    position: relative;
    things stack up according to order

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    can i ask why you didnt put div inside the menu.php file in bluewalrus's first reply.

    lke, menu.php:

    Code:
    <div id="menu">
    <ul> 
    <li>Home</li> 
    <li>Photos</li> 
    <li>Links</li> 
    </ul>  
    </div>

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    cool, thank you

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •