December 15, 200916 yr I am working on my portfolio website. It is a personal project as well as a school assignment, so it needs to get done either way. I need help planning what I should do. I already talked with my prof about it but I am having trouble with what I have done so far and I think it might be best to start over. Here is a screenshot of my .psd layout and what I would like my website to look like. If you have any questions, just ask. Currently I have everything in divs and in order to get each section to load, I am use a jQuery hide and unhide function. This is making my code super messy and I am having trouble getting the pages to work to my liking. Is there another way for me to set up my site? Any help or advice is appreciated!!
December 15, 200916 yr Currently I have everything in divs and in order to get each section to load, I am use a jQuery hide and unhide function. This is making my code super messy and I am having trouble getting the pages to work to my liking. What do you mean by that, your trying to load the pages with Ajax ?
December 15, 200916 yr Author What do you mean by that, your trying to load the pages with Ajax ? Here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script type="text/javascript" src="js/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ //prepend span tag $(".photo a").prepend("<span></span>"); }); </script> <script type="text/javascript"><!-- $(document).ready(function(){ $("#home").click(function(){ $("#aboutMeContent").hide(); $("#homeContent").show(); $("#workContent").hide(); $("#blogContent").hide(); }); $("#about").click(function(){ $("#aboutMeContent").show(); $("#homeContent").hide(); $("#workContent").hide(); $("#blogContent").hide(); }); $("#work").click(function(){ $("#workContent").show(); $("#homeContent").hide(); $("#aboutMeContent").hide(); $("#blogContent").hide(); }); }); //--></script> <style type="text/css"> <!-- body { font: 100% Verdana, Arial, Helvetica, sans-serif; background: url(images/background.png); margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */ padding: 0; text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */ } /* Tips for Elastic layouts 1. Since the elastic layouts overall sizing is based on the user's default fonts size, they are more unpredictable. Used correctly, they are also more accessible for those that need larger fonts size since the line length remains proportionate. 2. Sizing of divs in this layout are based on the 100% font size in the body element. If you decrease the text size overall by using a font-size: 80% on the body element or the #container, remember that the entire layout will downsize proportionately. You may want to increase the widths of the various divs to compensate for this. 3. If font sizing is changed in differing amounts on each div instead of on the overall design (ie: #sidebar1 is given a 70% font size and #mainContent is given an 85% font size), this will proportionately change each of the divs overall size. You may want to adjust based on your final font sizing. */ .twoColElsLtHdr #container { width: 1000px; /* this width will create a container that will fit in an 800px browser window if text is left at browser default font sizes */ height: 1000px; background: none; margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */ border: none; text-align: left; /* this overrides the text-align: center on the body element. */ } .twoColElsLtHdr #header { background:url(images/header.png); height: 110px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */ } .twoColElsLtHdr #header h1 { margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */ padding: 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */ } /* Tips for sidebar1: 1. Be aware that if you set a font-size value on this div, the overall width of the div will be adjusted accordingly. 2. Since we are working in ems, it's best not to use padding on the sidebar itself. It will be added to the width for standards compliant browsers creating an unknown actual width. 3. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".twoColElsLtHdr #sidebar1 p" rule. */ .twoColElsLtHdr #sidebar1 { float: left; width: 260px; /* since this element is floated, a width must be given */ height: 838px; background: url(images/sidebar.png) /* the background color will be displayed for the length of the content in the column, but no further */ /* top and bottom padding create visual space within this div */ } .twoColElsLtHdr #sidebar1 h3, .twoColElsLtHdr #sidebar1 p { background:url(images/sidebar.png); margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */ margin-right: 10px; } /* Tips for mainContent: 1. If you give this #mainContent div a font-size value different than the #sidebar1 div, the margins of the #mainContent div will be based on its font-size and the width of the #sidebar1 div will be based on its font-size. You may wish to adjust the values of these divs. 2. The space between the mainContent and sidebar1 is created with the left margin on the mainContent div. No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends. 3. To avoid float drop, you may need to test to determine the approximate maximum image/element size since this layout is based on the user's font sizing combined with the values you set. However, if the user has their browser font size set lower than normal, less space will be available in the #mainContent div than you may see on testing. 4. In the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This avoids several IE-specific bugs that may occur. */ .twoColElsLtHdr #mainContent { width: 740px; /* the right margin can be given in ems or pixels. It creates the space down the right side of the page. */ height: 790px; background:url(images/content.png); float: right; } .twoColElsLtHdr #footer { /* this padding matches the left alignment of the elements in the divs that appear above it. */ background: url(images/footer.png); float: left; height: 51px; width: 1000px; } .twoColElsLtHdr #footer p { margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */ padding: 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */ } /* Miscellaneous classes for reuse */ .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */ float: right; margin-left: 8px; } .fltlft { /* this class can be used to float an element left in your page */ float: left; margin-right: 8px; } .clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */ clear:both; height:0; font-size: 1px; line-height: 0px; } #nav { float: right; } #homeContent { } #aboutMeContent, #workContent, #blogContent { display:none; } #workContent { display: none; } --> </style><!--[if IE]> <style type="text/css"> /* place css fixes for all versions of IE in this conditional comment */ .twoColElsLtHdr #sidebar1 { padding-top: 30px; } .twoColElsLtHdr #mainContent { zoom: 1; padding-top: 15px; } /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */ </style> <![endif]--></head> <body class="twoColElsLtHdr"> <div id="container"> <div id="header"> <div id="header"></div> <div id="nav"><img src="images/home.png" width="159" height="48" id="home" /><img src="images/about.png" width="180" height="48" border="0" id="about" /><img src="images/work.png" width="178" height="48" border="0" id="work" /><img src="images/blog.png" width="223" height="48" id="blog" /></div> <!-- end #header --></div> <div id="sidebar1"></div> <!-- end #sidebar1 --> <div id="mainContent"> <div id="homeContent">Home content goes here</div> <div id="aboutMeContent">About Me goes here</div> <div id="workContent"> <style type="text/css"> body { margin: 0; padding: 0; width: 750px; font: 70%/140% Arial, Helvetica, sans-serif; } h1 { font: normal 390%/110% Garamond, Georgia, serif; letter-spacing: -2px; text-transform: uppercase; text-align: center; padding: 30px 0 0; margin: 0; } img { border: none; } .next_scribble { float: right; height: auto; width: auto; position: relative; margin: 30px 30px 25px 3px; padding: 650px 40px 20px 2px; } /* ---------- gallery styles start here ----------------------- */ .gallery { list-style: none; margin: -10px; padding: 25px; } .gallery li { margin: 15px; padding: 0; float: right; position: relative; width: 150px; height: 150px; } .gallery a { text-decoration: none; color: #999; } .gallery a:hover { color: #000; text-decoration: underline; } .gallery img { border: none; padding: 20px 15px 1px 2px; } .gallery em { width: 150px; height: 65px; display: block; position: absolute; top: -20px; left: -22px; background: url(portfolio/polaroid_smallv3.png); text-align: center; font: italic 100%/100% Georgia, "Times New Roman", Times, serif; padding-top: 105px; } </style> <ul class="gallery"> <li><a href="#"><em></em><img src="portfolio/images/thumbnails/v2/airportmap.png" alt="image" /></a></li> <li><a href="#"><em></em><img src="portfolio/images/thumbnails/v2/bmw.png" alt="image" /></a></li> <li><a href="#"><em></em><img src="portfolio/images/thumbnails/v2/getserious.png" alt="image" /></a></li> <li><a href="#"><em></em><img src="portfolio/images/thumbnails/v2/hotdocs.png" alt="image" /></a></li> <li><a href="#"><em></em><img src="images/3" alt="image" /></a></li> <li><a href="#"><em></em><img src="images/6.jpg" alt="image" /></a></li> <li><a href="#"><em></em><img src="images/3.jpg" alt="image" /></a></li> <li><a href="#"><em></em><img src="images/1.jpg" alt="image" /></a></li> <li><a href="#"><em></em><img src="images/2.jpg" alt="image" /></a></li> </ul> <div id="next_scribble"><img src="images/next_scribble.png" width="100" height="50" class="next_scribble"/></div> </div> <div id="blogContent">Blog goes here</div> </div> <!-- end #mainContent --> <div id="footer"> <!-- end #footer --> </div> <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --> </div> <!-- end #container --></div> </body> </html>
December 15, 200916 yr To make it look better, you should remove all the style information from that page and move it to a stylesheet file - save everything in the <style> tags (not the tags themselves) and put them in a document called "stylesheet.css". Then, just link in the stylesheet at the top of the page. Anywhere in the <head> section add: <link rel="stylesheet" href="stylesheet.css" type="text/css" /> That should remove a lot of the excess from your page. For the Internet Explorer styles, move them to a stylesheet called "iestyles.css" and then link them in by having the following in the <head> <!--[if IE]> <link rel="stylesheet" href="iestyles.css" type="text/css" /> <![endif]-->
December 15, 200916 yr If your worried about your code being messy you should definitely have your css and javascript in external files, you should be doing that anyway As for jQuery I'm no expert but it looks to me like your over complicating it a bit, could you not use something a bit more simple like this: You would need to separate your content up into pages rather than specific divs, but this would help you with SEO anyway. Edit: here we go.. <script type="text/javascript"> //Ajax Page Load Function// $(document).ready(function(){ $("#home").click(function() { //load index.html into content div on click $("#content").load("index.html"); }); $("#about").click(function() { //load about.html into content div on click $("#content").load("about.html"); }); /////// etc... /////// }); </script> Hope this helps..
December 15, 200916 yr Author Oooh, yes! That is what I was wondering... if that sort of thing was possible. So I can make each page separately then?
December 15, 200916 yr There's a really good tutorial to achieve want you want on NetTuts here I remember bocaj (member on here) mentioning that he has an updated version which is better for search engines - I guess you could contact him to see if he still has it.
December 15, 200916 yr Author Ugh, I am still having trouble. I'm having trouble linking the external files when I put the CSS in its own file and the page doesn't show up properly.
December 15, 200916 yr Yh it's sort of like a PHP Include, you just have your html content for that page e.g about.html would just have.. <h1>About Me</h1> <div> blah blah blah blah blah blah </div> and this would get loaded into your content div, to be honest though I don't really see why loading the page with Ajax is necessary for what you are doing.. correct me if I'm wrong however Edit: With linking the files you need to be very careful with the location of the file, a missing '/' can cause chaos And I've just looked, the tutorial Mr Brightside posted is very good
December 15, 200916 yr Author Ok, so I am cleaning it up. Got the linking to external files working. My website is totally screwing up now though. The divs won't load, etc. Most of the design shows up in Dreamweaver, but the content background and footer aren't there and when I preview it in Safari or FF all I see is the background image and the main nav. Here is my main code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" href="css/stylesheet.css" type="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script type="text/javascript" src="js/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ //prepend span tag $(".photo a").prepend("<span></span>"); }); </script> <script type="text/javascript"><!-- $(document).ready(function(){ $("#home").click(function(){ $("#aboutMeContent").hide(); $("#homeContent").show(); $("#workContent").hide(); $("#blogContent").hide(); }); $("#about").click(function(){ $("#aboutMeContent").show(); $("#homeContent").hide(); $("#workContent").hide(); $("#blogContent").hide(); }); $("#work").click(function(){ $("#workContent").show(); $("#homeContent").hide(); $("#aboutMeContent").hide(); $("#blogContent").hide(); }); }); //--></script> </head> <body class="twoColElsLtHdr"> <div id="container"> <div id="header"> <div id="header"></div> <div id="nav"><img src="images/home.png" width="159" height="48" id="home" /><img src="images/about.png" width="180" height="48" border="0" id="about" /><img src="images/work.png" width="178" height="48" border="0" id="work" /><img src="images/blog.png" width="223" height="48" id="blog" /></div> <!-- end #header --></div> <div id="sidebar1"></div> <!-- end #sidebar1 --> <div id="mainContent"> <div id="homeContent">Home content goes here</div> <div id="aboutMeContent">About Me goes here</div> <div id="workContent"> </div> <div id="blogContent">Blog goes here</div> </div> <!-- end #mainContent --> <div id="footer"> <!-- end #footer --> </div> <!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --> </div> <!-- end #container --></div> </body> </html>
Create an account or sign in to comment