CSSBytes

Helping You With Your CSS

  • Blog Goals:

    • Getting it's own domain.

    • Creating a completely unique layout for it.

    • Becoming very well-known across the CSS community.

    • Most Importantly:

      To help you with your CSS!

  • CSS & HTML Help

  • Subscribe

  • Blog Stats

    • 11,038 hits

Archive for the ‘Positioning’ Category

Lesson 28 – Position:Fixed

Posted by cssbytes on November 8, 2007

Absolute positioning is good, very good, in fact, but sometimes you may end up in a situation where it’s not the answer. This is where fixed positioning comes in. Does the word ‘fixed’ sound familiar? If it does, you’re right to think so. Think back to this post, with the non-repeating backgrounds, and you’ll find out. Except, with Divs, you need to position it in pixels, not just by typing ‘center’, or ‘left bottom’, etc. Here’s the code you’ll need:

#IDNAMEGOESHERE
{
border: 2px groove #3399DD;
font: 12px Arial;
text-indent: 3px;
height: 200px;
width: 300px;
overflow: auto;
position: fixed;
left: 100px;
top: 100px;
right: 100px;
bottom: 100px;

}
  • There’s not much to it, really, is there? It’s very similar to absolute positioning, except that you put “position: fixed;” rather than “position: absolute;”.
  • Remember that you can’t position it using left, right, top and bottom. You can only use combinations such as left bottom, and right top.
  • This will have the same effect as it did on your backgrounds. When you scroll down on your page, the Div Box will remain in the same position, always. At times this can be very useful, for features on your webpage such as navigation, for instance.

The only warning I’ll give you, is to be careful where you position your Div Box in relative to other text that you may have on your page. You don’t want to have your fancy Div blocking all of your text, now do you? Bye.

Posted in Absolute Positioning, CSS, Divs, Fixed Positioning, ID's, Images, Layouts, Positioning | Leave a Comment »

Lesson 27 – Positioning Your Div Box

Posted by cssbytes on October 23, 2007

So, now you have your Div boxes. Great! You’ve made yourself a simple layout now. But the trouble is, you can only put these boxes on the far left, far right and centre of your page. This is where positioning comes in. Now you can put your Div boxes, wherever you want them. But be careful – this can go very wrong… Anyway, let’s start with the code:

#IDNAMEGOESHERE
{
border: 2px groove #3399DD;
font: 12px Arial;
text-indent: 3px;
height: 200px;
width: 300px;
overflow: auto;
position: absolute;
left: 100px;
right: 100px;
top: 100px;
bottom: 100px;

}
  • Woah, that’s a lot of coding, isn’t it. Well don’t worry, you already know most of it, from here, so you only need to concentrate on the text that is coloured.
  • So what is the coloured text? Basically, that’s what will position your Div box wherever you want it, and you don’t even need all of it
  • The “position: absolute;” part, tells the web browser that your Div box will always be in a certain place on the page. For example, it could be 100 pixels from the left of the window, and 100 pixels from the top of the window.
  • You can customize everything coloured, except for the “position: absolute;” part (I’ll get onto that in a later post). But you only need to use two of the options (i.e: top & left, right & bottom).
  • Make sure that when you position your boxe, they don’t conflict with your padding or margins, or cover up some other text on the page, because it looms messy and unprofessional.
  • But finally, the most important tip: don’t position your Div boxes just for your computer, and your computer alone – the chances are, your layout will work for your computer, and your computer alone. Be aware that some people will have different screen resolutions to you.

And that’s it for now. If you’ve forgotten the HTML code for your Div box, then click here. (The positioning will not affect this code). Bye for now, and have fun positioning your Div boxes. (I know that sounds really sad…)

Posted in Absolute Positioning, Aligning, CSS, Divs, HTML, ID's, Layouts, Margins, Padding, Positioning | 1 Comment »