Showing posts sorted by relevance for query css. Sort by date Show all posts
Showing posts sorted by relevance for query css. Sort by date Show all posts

CSS 2.1 and CSS 3 Help Cheat Sheets (PDF)

Today we are glad to release two useful cheat sheets that will help you quickly look up the right CSS 2.1-property or an obscure CSS 3 property. The style sheets contain most important properties, explanations and keywords for each property. The help sheets were created by GoSquared and released for Smashing Magazine and its readers.

Download the cheat sheets for free!


Content Source : Smashing Magazine

Minimum Width for a Page

A very handy CSS command that exists is the min-width command, whereby you can specify a minimum width for any element. This can be particularly useful for specifying a minimum width for a page.
Unfortunately, IE doesn't understand this command, so we'll need to come up with a new way of making this functionality work in this browser. First, we'll insert a

under the tag, as we can't assign a minimum width to the :


Next, we create our CSS commands, to create a minimum width of 600px:
#container
{
min-width: 600px;
width:expression(document.body.clientWidth <>

The first command is the regular minimum width command; the second is a short JavaScript command that only IE understands. Do note, though, that this command will cause your CSS document to become invalid; you may prefer to insert it into the head of each HTML document to get around this.
You might also want to combine this minimum width with a maximum width:
#container
{
min-width: 600px;
max-width: 1200px;
width:expression(document.body.clientWidth <> 1200? "1200px" : "auto");
}

Touch The Future: Create An Elegant Website With HTML 5 And CSS3

Demo | Download

I’m sure that who chooses to work as web designer makes a choice of heart, a choice of love. He/she decides to bet any given day on his creativity and his ability of producing an idea and of making it tangible, visible and perceptible for all. These crazy men have my respect. But, also when the creative side is very important for a work, there exists a logical (and technical) part in all creative process.

There are some moments and situations in which the creative mind needs an analytical method to achieve the objective, that is, for us, the creation of a well-done website.

In his article on Design Informer titled “Web Design Iterations And Algorithm,” Adit Gupta explains how we can approach a web design work and how a website project can be processed in a number of iterations following a main algorithm. Well, generally it’s just how Adit has described.
Our brain works well, in order to solve a big problem, if we can divide the main issue in N operations that solve N little difficulties, and the total sum of these N little steps provides the solution for our big problem. Perfect, ‘Houston, we have a big problem!’ We should create a working web design. Actually the common routine requires the following main steps:

  • Step 1: understand the theme and the topics of the website and decode the client’s requests
  • Step 2: choose the right style and sketch your ideas
  • Step 3: draw a clean and clear wireframe to summarize the structure of the website
  • Step 4: design the website (in pixels) through an image editor, like Photoshop, to create a real-scale mockup
  • Step 5: convert your psd mockup to HTML and CSS

Five macro-steps to build an effective website using brain, pencil, paper, Photoshop, HTML and CSS. But technology doesn’t stop, luckily, and we have other two great allies for the future to design better website: HTML 5 and CSS3.

Read more

Making web pages extend to the bottom of the browser window

Introduction

If you ever made a web site with the content in a center column and a different background for the body, or with a short lateral navigation bar, probably you experienced the problem of some elements not extending to the bottom of the browser window when the height of the content is lesser than the document area of the browser window.

For simple designs, like pages with a side navigation bar and the rest of the page for contents, faking the layout with a background image can be enough to fix the problem, but for more complex layouts real full height element usually are required. For that cases we can resort to JavaScript to perform some DOM manipulation magic.

The CSS layout

I'm going to use a layout with one fixed-width centered content area, a menu at the top of it and some decorations at the top and bottom of the content area. Let's take a look to the CSS code:

body {
padding: 0;
margin: 0;
background: White url(img/img_116.gif);
text-align: center; /* IE 5.x */
}

#menu {
width: 650px; /* IE 5.x */
width/**/:/**/ 610px;
margin: 0 auto;
padding: 10px 20px;
background: transparent url(img/sample-menu-border.gif) repeat-y left top;
text-align: left;
}

#contents {
position: relative;
width: 650px; /* IE 5.x */
width/**/:/**/ 500px;
margin: 0 auto;
padding: 50px 75px 30px;
background: transparent url(img/sample-contents-border.gif) repeat-y left top;
text-align: justify;
}

You can see a couple of examples of a page with a lot of content and a page with very few content. If you are wondering about the "/**/:/**/", it's an alternative fancy method to the box model hack.

Fixing the layout

The JavaScript fix involves getting the size of the document element and the container we want to resize (in this case #contents), and the position of this element. There is no standard DOM attribute for this, but almost all browsers support the offsetHeight and offsetTop attributes (although Opera needs a bit of tweaking for getting the height of the document).

Then we compare the size of the target element (#contents) with the size of the document minus the top offset of that element. If it's smaller, then a style rule with the proper height is applied to #contents (making a difference for IE 5.x due to its broken box model). Also, the code is attached to the onresize event for readjusting the size if the user makes the browser window bigger.

The resulting JavaScript code would be something like this:

var isIE5=navigator.userAgent.toUpperCase().indexOf("MSIE 5")!=-1;

var targetElementID="contents", targetElementStyleOffset=80;

function adjustHeight() {
if (document.getElementById) {
var targetElement=document.getElementById(targetElementID),
documentHeight, totalOffset;

if (targetElement && document.documentElement.offsetHeight
&& targetElement.offsetHeight && targetElement.offsetTop) {
documentHeight=document.documentElement.offsetHeight;
if (targetElement.offsetHeight

Also, for making the script work in Opera 8 and Konqueror 3.4 we need to set the height of the html element to 100%:

html {
height: 100%;
}

For using the code you only need to modify two values and include a call to the function. First, you need to change the values that appear in bold in the script to reflect the following data:

  1. The ID of the element that need to be extended (#contents in the previous example, so we'll use the string "contents").
  2. The vertical offset generated by the styles applied to the element (margin, padding and border). In the example we have:
    padding: 50px 75px 30px;
    margin: 0 auto;
    so we use 80 for the style offset. This offset is not applied to IE 5.x due to its broken box model. See the notes below for an explanation of this.

For activating the script, we can use the onload event, but the best method is including also a call to the adjustHeight() function just before closing the body tag, like:

This usually works fine since all the DOM objects are already defined at that point, and it's much faster that using the onload event, because this event doesn't trigger until all the page is loaded (images and ads included). Anyway, assigning the function to the event ensures that the function will be called.

Following the next link you can see an example of the page with the JS fix applied.

The script works in Firefox/Mozilla, Internet Explorer 5/6/7, Opera 7/8, Konqueror 3.4, Safari and Omniweb (thanks to Stephen Caudill for the Mac feedback), which adds a nice 99% of the current browser pool :-) .

Notes and limitations

  • If you need to apply any padding and/or margin to the container you want to resize, you have to express it in pixels, since the script needs that value for setting the proper height. Since the box model doesn't include padding and margin in the dimensions of the boxes, and I was unable to find a reliable way to get the margin and padding values from JS, this manual workaround is needed.
  • The script doesn't downsize the target container, only enlarges it. Take into account that the goal of the script is getting a page that extend at least to the bottom of the browser window, not a page that fits always in the browser document area.
  • The script doesn't work when the user changes the base font size in the browser after the page is loaded. Simply there is no JS event to catch this. Anyway, the next time the page is loaded with the new size, the script will work fine.

How To Create Depth And Nice 3D Ribbons Only Using CSS3


In this last period on PV.M Garage we have described many trends of the modern Web Designand many techniques for creating stunning and impressive web sites.
In one of our tutorials we learned how to realize a nice 3D ribbon and how to play with the drop shadow in Photoshop to simulate depth in a web design layout. This is a widespread trends in recent web design: creating a 3D perception in a website and simulating a “world” in three dimensions are two great ways for the designers to play with their skills.
Thanks to useful graphic softwares (2D) we can easily create 3D elements, like ribbons and shadows, but we can also reproduce 3D scene using perspective, focus, color shading and opacity. There is also the possibility of using 3D softwares, like Blender, to create some 3D objects and images that we can use in our designs. There is an interesting article onCreativityDen about the fundamental ways of adding depth in web design works; it explains six basic techniques to simulate the 3D perception in our works and I suggest an attentive reading.
Many beautiful web sites have a wonderful, balanced, three-dimensional perception and it’s clear that this kind of layouts use, in a clever way, images (generally in the background property), lines and some CSS techniques to create the illusion of depth (there is a brilliant post, by Henry Jones on Web Design Ledger, about the use of 1px line to simulate the depth). Some examples.