Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Need Help With Floating Layout!, Any coding experts out there?
DigitalDingo
post Aug 28 2005, 10:26 AM
Post #1


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 40
Joined: 24-July 05
Member No.: 7,405



First: I’m sorry, but I don’t know to which sub forum this topic belongs. Maybe a kind moderator will move this in the future.

And now to my question:
I’m currently building a new website which can be rather hard if you don’t know anything about coding (!). tongue.gif
This is how I want my website to look like:


Now, my question is if it’s possible to make my content box float while the left box (with the buttons) stays on top (where it is now)?
I bet there is a solution, but as I said I’m no coding expert.

At my other website I used this code to make it float:

CODE
<tr>
 <td colspan="10">
  <img src="images/content-top.gif" width="720" height="7" alt=""></td>
</tr>
<tr>
 <td colspan="10" style="background:url('images/content-loop.gif');background-repeat:repeat-y;" width="685" height="100%">
<div style="position:relative; left:15px; height:300px;">Here goes the content!</div>
 </td>
</tr>
<tr>
 <td colspan="10">
  <img src="images/content-bottom.gif" width="720" height="8" alt=""></td>
</tr>

But this code doesn’t help me much now. The left box centres beside the floating content box and makes the layout useless.

Can anyone help me with a code to solve my problem? I would be extremely grateful! biggrin.gif
Attached File(s)
Attached File  layout.jpg ( 74.85k ) Number of downloads: 172
 
Go to the top of the page
 
+Quote Post
DigitalDingo
post Aug 28 2005, 10:28 AM
Post #2


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 40
Joined: 24-July 05
Member No.: 7,405



A better word for "float" in this case would probably be "loop".

Just to avoid any misunderstandings... smile.gif
Go to the top of the page
 
+Quote Post
Hercco
post Aug 31 2005, 05:40 PM
Post #3


Super Member
Group Icon

Group: Members
Posts: 595
Joined: 4-September 04
Member No.: 228



Do you mean that the content box would have a higher height than the menu but the menu would still stay at the top?
Go to the top of the page
 
+Quote Post
szupie
post Aug 31 2005, 09:11 PM
Post #4


S.P.A.M.S.W.A.T.
Group Icon

Group: Members
Posts: 814
Joined: 22-January 05
From: San Antonio, Texas (No, I'm not dumb. I just moved here...)
Member No.: 2,284



This is best to be done with CSS. You would create a div for the header part, another div for the left box, and a last div for the content box. In your CSS, make the left box div float left and give the content box div a relative positioning.
This isn't very detailed, but I lost my code that I wrote, and its layout is similar to yours. So if you need more help, ask me, and I'll look up more things for you.
Go to the top of the page
 
+Quote Post
DigitalDingo
post Sep 2 2005, 06:13 PM
Post #5


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 40
Joined: 24-July 05
Member No.: 7,405



QUOTE
Do you mean that the content box would have a higher height than the menu but the menu would still stay at the top?


Yup, that's what I mean. And the content box should expand to the the text in it.

QUOTE
This is best to be done with CSS. You would create a div for the header part, another div for the left box, and a last div for the content box. In your CSS, make the left box div float left and give the content box div a relative positioning.
This isn't very detailed, but I lost my code that I wrote, and its layout is similar to yours. So if you need more help, ask me, and I'll look up more things for you.


Thanks, I'll try to find some CSS scripts on some coding page then. smile.gif
Go to the top of the page
 
+Quote Post
szupie
post Sep 2 2005, 10:15 PM
Post #6


S.P.A.M.S.W.A.T.
Group Icon

Group: Members
Posts: 814
Joined: 22-January 05
From: San Antonio, Texas (No, I'm not dumb. I just moved here...)
Member No.: 2,284



Yay, I got my codes back from my old computer. I will show you part of my CSS file, and I added some comments to explain what some declarations mean. I deleted some of the irrelevant parts, like background colors.

CODE
/* div specs start */

#topmenu {   /* In your case, this would be the Header */
 margin: 5px 50px 0 50px;   /* Gives the div some space outside */
 padding: 0 5px 5px 5px;   /* This gives some space between the div's border and it's inside. This keeps text inside from starting/ending rigth at the edge of the div */
}


/* Container of expandable middle part starts */
#container {
 position: relative;   /* Places div at the next spot available. Also, this makes the div expandable. Absolutely positioned divs do not resize. */
 margin: 5px 50px 0 50px;
 padding: 0;
}

#sidemenu {   /* This sidemenu will be where you would put your polls and buttons. It goes inside the container. */
 float: left; /* float to the left */
 padding: 0;
 margin: 0;
 height: 100%;   /* This statement makes the div stretch its height to all of the available space in the container, therefore allowing expansion and contraction. */
 width: 185px;   /* This keeps the sidemenu at a smaller size than the content. You can use % if you want. */
}

#content {
 position: relative;   /* Places it next to sidemenu. Also, this makes the div expandable. Absolutely positioned divs do not resize. */
 height: 100%;
 margin-left: 190px;   /* sidemenu width (185) + 5 */
}

#expander {   /* This part is required if you want something below your contents. If you don't have this, the div below will come up inside the contents div, and they will overlap */
 margin: 0;
 padding: 0;
 height: 0;
 clear: both;   /* This statement is used to make nothing go over the div. If something gets in its way, it moves. */
}
/* Container of expandable middle part ends */


#copyright {
 position: relative;
 margin: 10px 50px;
 padding: 0;
}

/* End of div specs */


Well, that's pretty much it... If you got any questions, ask.
Go to the top of the page
 
+Quote Post
DigitalDingo
post Sep 10 2005, 09:53 AM
Post #7


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 40
Joined: 24-July 05
Member No.: 7,405



Thank you so much for your help.

Now, there is actually a little question. It doesn’t really have anything to do with the CSS script (a friend told me I probably would need PHP).

My question is: when you click a button, is it possible to make the page it links to open in the content? I mean without reloading the entire page every time you click a button?

I have done it with IFrames in HTML before, but I don't want to spoil a CSS layout with some ugly looking frames. smile.gif

Can anybody help me here?
Go to the top of the page
 
+Quote Post
Hercco
post Sep 15 2005, 10:34 PM
Post #8


Super Member
Group Icon

Group: Members
Posts: 595
Joined: 4-September 04
Member No.: 228



QUOTE(DigitalDingo @ Sep 10 2005, 11:53 AM)
My question is: when you click a button, is it possible to make the page it links to open in the content? I mean without reloading the entire page every time you click a button?
*




It is possible, but would also mean that you would have to load all the "pages" which you want to be opened without a reload, thus making your index file larger.

Anyways, if the content isn't anything heavy that would actually be quite nice to browse.

This is how you do it:

You make each of the "pages" a separate <div>. You should probably make a CSS class called content (or whatever) and use it for all the divs. The class would contain at least the positioning code, so that each of your "pages" (ie. divs) would appear at the same place.

Each of these divs should be given an unique id. Such as "links" or "guestbook".

A div could look like this:

CODE


<div id="guestbook">
Guestbook goes here
</div>



Then with CSS, you set one div:

CODE

display: block;



And all others
CODE

display: none;



Then you need to use javascript to change the "page". The function could look like this:

CODE


 function change( item )
 {  
  element=document.getElementById(item);
  current.style.display="none";
  element.style.display="block";
  current = element;
 }



Notice that before the function, you should have set a value for "current". This line before the function:

CODE

current=document.getElementById("index");


"Index" being there the id of the div which you which to have opened as a default.


About that function, it simply gets the element by the id given as a parameter to it, sets the currently active page not to be displayed and the new element to be displayed as block. Finally the now activated element is set as "current" for the next time the function is called.


For the buttons simply user onClick like this:

CODE


<span onclick="change('guestbook');">Guestbook</span>



The html element of course can be whatever you want (and image for example). But don't use links (<a></a> tags) since you always have to specify href value for them. You could put # there but it would cause annoying scrolls to the top. I'd recommend usings <span>s or images and using a CSS class for them specifying:
CODE

cursor: pointer;

which makes the cursor appear as the hand over the element, thus indicating a link-like behavior.

And that's it!


One problem arises with this kind of design though. It is the same as with using iFrames: people cannot link to exact pages. However you could do somekind of workaround for it, with PHP for example. Offer links to users with the page intended to be displayed specified as GET data. Like this: yousite.com/index.php?page=guestbook . And then with PHP set which div is set as display: block; on the page load.
Go to the top of the page
 
+Quote Post
DigitalDingo
post Sep 17 2005, 06:33 PM
Post #9


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 40
Joined: 24-July 05
Member No.: 7,405



Hmm... I’ve played a little with these codes, but I just can’t figure out where to put them. It’s especially the JavaScript part I have troubles with. And do you mean, that I should put all these codes – and the all the pages – in the same file?
Maybe you could put your codes together so I can see where to put them in my own file.
Maybe I should also tell you, that the layout I attached to this thread is no longer the one I’m working with. If it could help you, you can find my site at www.twilight.astahost.com and see the source code.

And thanks for helping me here! smile.gif
Go to the top of the page
 
+Quote Post
szupie
post Sep 18 2005, 12:34 AM
Post #10


S.P.A.M.S.W.A.T.
Group Icon

Group: Members
Posts: 814
Joined: 22-January 05
From: San Antonio, Texas (No, I'm not dumb. I just moved here...)
Member No.: 2,284



Well, you can put your javascript in your html, inside the script tag like this:

CODE
<script type="text/javascript">
/*<![CDATA[*/
print "This is the script..."
/*]]>*/
</script>

Make sure that is placed in the head.
And for the CSS, you can put them like this:
CODE
<style type="text/css">
/*<![CDATA[*/
thing {
 color: #fff;
}
/*]]>*/
</style>

, also in the head area.

And yes, he meant to put all the pages in one file, and use javascript to show and hide them. For example, when people go to your home, they would go to index.htm, and javascript will show only the "home" portion, while hiding all the other portions of the page. When they go to, say, an "about" page, they would not go to a new page, but instead, javascript will hide the "home" portion, and show the "about" portion only. If your pages are really large, it would take a long time to load everything on just the index page. But if all of your pages are really small and you have only a few pages, that idea could be used.
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Div Tags Vs Tables For Layout(10)
  2. Table Layout Vs. Css Layout(18)
  3. Css Coding(3)
  4. Free Code Snippets And Css Layout(12)
  5. 3 Column Css Layout(13)
  6. Coding Layouts(4)


 



- Lo-Fi Version Time is now: 7th September 2008 - 11:37 PM