Web Development Thread, How to modularize CSS menus in Coding and Web Development; hi all,
Here's a question to be sure: how do I modularize CSS menus? In other words, I want to ...
-
29th January 2009, 12:02 PM #1
- Rep Power
- 0
How to modularize CSS menus
hi all,
Here's a question to be sure: how do I modularize CSS menus? In other words, I want to define a menu (e.g., orange Tree Horizontal Menu) once, and then call/invoke it from any number of pages. Is this possible, or must I duplicate the HTML code in every page? Seems to me that last method would be inefficient, since a change to the menu would require a change to each and every page. Please help me.
Thanks
------------------------------
software development company
-
-
IDG Tech News
-
29th January 2009, 05:20 PM #2
- Rep Power
- 11
If you create the menu's css in an external file. You can call that css page from any page. You would have to create the divs, tables, hyperlinks etc for each page. However, just add the id of each 'object' for the css to style.
So you might have an external css page like:
(default.css)
div.menu {
background-color: #000;
color: #f00;
}
Then in a the html pages you can call the default.css page.
<html>
<head>
<link rel="stylesheet" type="text/css" href="default.css" />.
<title>Page Using CSS</title>
</head>
<body>
<div id="menu">My Menu</div>
</body>
</html>
Hope this helps
-
-
29th January 2009, 08:35 PM #3
- Rep Power
- 11
You would have to create the divs, tables, hyperlinks etc for each page.
... unless you save your pages as .php instead of .html . If you do that then you can cut/paste your menu html into a separate file (say... 'menu.html') and include it on each page :
PHP Code:
<html>
<head> ... stuff (including of course linking to style sheets) ... </head>
<body>
<?php include 'menu.html'; ?>
<div id="body-copy">
<h1>Header</h1>
<p>Body of your page</p>
</div>
</body>
</html>
This is assuming of course that your hosts provide php (most do these days). You have to save it as .php so that the server knows to look for <?php and ?> tags which signal the start and end of php code. "include" gets the server to replace that bit with the contents of menu.html . It's pretty straight-forward and will save you time when you go to add a new menu item or re-structure the site (as innevitably happens eventually).
Hello
:-Dave
-
SHARE:
Similar Threads
-
By wesleyw in forum EduGeek Joomla 1.5 Package
Replies: 3
Last Post: 22nd October 2008, 09:17 AM
-
By HodgeHi in forum EduGeek Joomla 1.5 Package
Replies: 6
Last Post: 2nd June 2008, 11:38 AM
-
By jkmoch in forum EduGeek Joomla 1.0 Package
Replies: 2
Last Post: 5th May 2008, 03:28 AM
-
By kerlj001 in forum EduGeek Joomla 1.0 Package
Replies: 10
Last Post: 27th February 2008, 11:51 AM
-
By ianaddisonuk in forum Web Development
Replies: 0
Last Post: 12th August 2007, 02:01 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules