Skip to main content

CSS Positioning

Position:Static

The default positioning for all elements is position:static, which means the element is not positioned and occurs where it normally would in the document.
Normally you wouldn’t specify this unless you needed to override a positioning that had been previously set.

#div-1 {   
position:static; }

 

Position:Relative

If you specify position:relative, then you can use top or bottom, and left or right to move the element relative to where it would normally occur in the document.

Let’s move div-1 down 20 pixels, and to the left 40 pixels:

#div-1 {   
position:relative;
top:20px;
left:-40px; }

Notice the space where div-1 normally would have been if we had not moved it: now it is an empty space. The next element (div-after) did not move when we moved div-1. That’s because div-1 still occupies that original space in the document, even though we have moved it.

It appears that position:relative is not very useful, but it will perform an important task later in this tutorial.

Position:Absolute

When you specify position:absolute, the element is removed from the document and placed exactly where you tell it to go.

Let’s move div-1a to the top right of the page:

#div-1a {   
position:absolute;
top:0;
right:0;
width:200px; }

Notice that this time, since div-1a was removed from the document, the other elements on the page were positioned differently: div-1b, div-1c, and div-after moved up since div-1a was no longer there.

Also notice that div-1a was positioned in the top right corner of the page. It’s nice to be able to position things directly the page, but it’s of limited value.

What I really want is to position div-1a relative to div-1. And that’s where relative position comes back into play.

Footnotes
  • There is a bug in the Windows IE browser: if you specify a relative width (like “width:50%”) then the width will be based on the parent element instead of on the positioning element.
Position:Relative + Position:Absolute

If we set relative positioning on div-1, any elements within div-1 will be positioned relative to div-1. Then if we set absolute positioning on div-1a, we can move it to the top right of div-1:

#div-1 {   
position:relative; }


#div-1a {
position:absolute;
top:0;
right:0;
width:200px; }
Two Column Absolute

Now we can make a two-column layout using relative and absolute positioning!

#div-1 {   
position:relative; }


#div-1a {
position:absolute;
top:0;
right:0;
width:200px; }


#div-1b {
position:absolute;
top:0;
left:0;
width:200px; }

One advantage to using absolute positioning is that we can position the elements in any order on the page, regardless of the order they appear in the HTML. So I put div-1b before div-1a.

But wait – what happened to the other elements? They are being obscured by the absolutely positioned elements. What can we do about that?

 

float

For variable height columns, absolute positioning does not work, so let’s come up with another solution.

We can “float” an element to push it as far as possible to the right or to the left, and allow text to wrap around it. This is typically used for images, but we will use it for more complex layout tasks (because it’s the only tool we have).

#div-1a {   
float:left;
width:200px; }
float columns

If we float one column to the left, then also float the second column to the left, they will push up against each other.

#div-1a {  
float:left;
width:150px; }


#div-1b {
float:left;
width:150px; }

float columns with clear

Then after the floating elements we can “clear” the floats to push down the rest of the content.

#div-1a {   
float:left;
width:190px; }


#div-1b {
float:left;
width:190px; }


#div-1c {
clear:both; }

Best Free Design Software: Image editing

  • GIMP – is the GNU Image Manipulation Program. It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
  • Picasa – is a free software download from Google that helps you to locate and organise all the photos on your computer, edit and add effects to your photos with a few simple clicks, share your photos with others through email, prints and on the web.
  • Paint.NET – is free image editing and photo manipulation software for computers that run Windows. It features an intuitive and innovative user interface with support for layers, unlimited undo, special effects, and a wide variety of useful and powerful tools. An active and growing online community provides friendly help, tutorials, and plugins.
  • Magnifier – has the following features: no popup adverts or spyware, easy to use with any other program, resizable magnification area, adjustable zoom factor, overlay a grid.
  • Easy Thumbnails – creates thumbnails and scaled copies of all your images. With Easy Thumbnails, you can find and process images individually, in groups, or in whole folders using a simple file selector and built-in image viewer.Thumbnails can be created in any existing folder or a new folder, and you can identify them clearly by adding a prefix or suffix to their names.FastStone Photo Resizer – is an image converter / resizer intended to enable users to convert, rename, resize, crop, rotate, change color depth, add text and watermarks to images in a quick and easy batch mode.
  • ImageDiff – allows you to compare two images side by side, and see a difference mask showing you the exact pixels that have changed. Features include: Compare images of different formats, including JPG, GIF, BMP, and TIF, PNG. Compare images of different proportions and imageDiff will scale and calculate the difference automatically.
  • IrfanView – is a fast and compact image viewer/converter. It is trying to be simple for beginners and powerful for professionals. Many supported file formats and features. Features include: multi-language support, Thumbnail option, slideshow, toolbar skins, fast directory browsing, batch conversion/editing, multipage editing, file search, change color depth, scanning, cut/crop, IPTC edit, capturing, lossless JPG operations, effects (sharpen, blur, Adobe Photoshop filters), EXE/SCR creating, many hotkeys, command line options and plugins.
  • FastStone Image Viewer – is a fast, stable, user-friendly image browser, converter and editor. It includes a high quality magnifier and a musical slideshow with 150+ transitional effects, as well as lossless JPEG transitions, drop shadow effects, image annotation, scanner support, histogram and much more. It supports all major graphic formats including BMP, JPEG, JPEG 2000, GIF, PNG, PCX, TIFF, WMF, ICO and TGA.
  • Inkscape – is an Open Source vector graphics editor, with capabilities similar to Illustrator, Freehand, CorelDraw, or Xara X using the W3C standard Scalable Vector Graphics (SVG) file format. Supported SVG features include shapes, paths, text, markers, clones, alpha blending, transforms, gradients, patterns, and grouping. Inkscape also supports Creative Commons meta-data, node editing, layers, complex path operations, bitmap tracing, text-on-path, flowed text, direct XML editing, and more.
  • SmoothDraw NX – is a powerful freehand drawing tool. It?s a limited free version of SmoothDraw. It produces the most smooth and expressive stroke through your tablet. It also smoothes mouse input for who don?t have a tablet.
  • SPRAY vector generator -is intended to produce helper objects for vector illustration software like Xara X, Corel Draw, Adobe photoshop. You generate huge number of circles with random position, fill, outline color; random paths, grids, and rays. You can place generated objects thru clipboard at your favorite illustration app. Developed for Xara X but also works with Corel Draw or Adobe Illustrator.
  • ParticleDraw – is a novel windows drawing program powered by a state of the art general system simulation engine. The brushes are dynamic systems of particles with interesting behaviours, which you can completely customise. Each brush is intricately tuneable with many underlying physical parameters and one can construct arbitrary systems of particles and use these as brushes.
  • InsightPoint – creates sophisticated illustration and layout for Web and print. When it comes to spell out and share your ideas, in text and in graphics as well, InsightPoint is the fastest and easiest way to get you there. Built on top of XML technologies, comprehensive object-oriented vector design tools, trivial learning curve, and smooth drawing experience.
  • Serif DrawPlus – is a powerful drawing and graphics software. You?ll be amazed how easy it is to create high quality graphics and animations without having to spend hours designing or pay for expensive training.
  • Project Dogwaffle Free – is a paint and animation programa for the PC developed in VB by special fx artist, animator & novelist Dan Ritchie and made available for free downloading and use.
  • AmitySource Userbar Generator is an easy-to-use program for generating unique and attractive userbars. With it you can create nice-looking userbar within five minutes and without any technical or artistical knowledge. It has everything you need for creating personal userbars: you can choose colors, special effect, pattern, a glow effect, an overlay image for your composition. AmitySource Userbar Generator allows to save the created userbar in different popular formats.
  • Terragen – is a scenery generator, created with the goal of generating photorealistic landscape images and animations. It is available for Windows and the Mac OS. At this stage in its development, Terragen is free for personal, noncommercial use.
  • uMark Lite – allows you to add a text or image watermark to your digital photos. You can choose from 9 pre-defined watermark placements, set a custom font, size, and color, as well as opacity level. The freeware version can batch process up to 50 images in a single run. The watermarked images are saved in a new folder, so your originals remain unchanged. 50 images at a go, adds uMark Lite watermark.
  • TouchArt Sampler – is a great way to learn the art and skills of performing live visuals and VJing. TouchPlayer and 21 interactive 2D and 3D animations (synths) are included in this sampler. Touch lets you manipulate visuals in real-time, giving you control of various parameters like lighting, color, textures, motion, video playback, and composing. Play some audio and you can sync visuals to the BPM.
  • Synfig Studio is a vector based 2D animation program. It is designed to be capable of producing feature-film quality animation. It eliminates the need for tweening, preventing the need to hand-draw each frame. Synfig Studio features spatial and temporal resolution independence, high dynamic range images, and a flexible plugin system.
  • AnimPixels is an animated movie software specialized in Isometric Pixel Art. Use your own movie components, or download them from the Web, to create a original pixelized animated movie. Download the free AnimPixels animation software. No evaluation period or limited feature.
  • UnFREEz -is a high-speed Windows application that will take any number of images, saved as separate GIF files, and create a single animated GIF from those images. What makes this program unique from its competitors? First and foremost, UnFREEz is freeware, which means you may use it forever without paying a cent or feeling the slightest bit guilty
  • LOOXIS Faceworx -is a free Software which creates a 3D head out of two standard 2D photos.You need two well illuminated pictures; one from the front (mugshot style) and one from the side. The software demands some skills in placing reference points and marking the contours of the face; mouth, nose, ears and eyes. The final 3D portrait can be saved and exported in the well known OBJ format.
  • Bryce – is known for creating photo-realistic 3D landscapes and featuring a shallow learning curve for beginners. Start out building or importing a landscape as impressive as the Grand Canyon. Populate it with buildings, people or any other object you create or from the extensive DAZ 3D library. The Light Lab provides you robust control over your sunsets, moonlight nights or high-noon ambiance.
  • Blender – is the open-source software for 3D modeling, animation, rendering, post-production, interactive creation and playback. It is available for all major operating systems under the GNU General Public License.
  • Google SketchUp – is a free, easy-to-learn 3D-modeling program with a few simple tools to let you create 3D models of houses, sheds, decks, home additions, woodworking projects, and even space ships. You can add details, textures, and glass to your models, and design with dimensional accuracy. You can place your finished models in Google Earth, share them with others by posting them to the 3D Warehouse, or print hard copies.
  • 3D Canvas – is a real-time 3D modeling and animation tool that incorporates an intuitive drag-and-drop approach to 3D modeling. Complex models can be constructed from simple 3D primitives, or created using 3D Canvas’ Object Building Tools. Modeling tools are provided to deform, sculpt, and paint 3D objects.
  • 3D Box Shot Maker – is an easy and FREE tool to virtually design quality box shot as your software box cover. It is important to present a professional boxshot to attract your potential customers to take a closer look at your products. An impressive box shot will make your software outstanding, and easily defeat your competitors at the start.
  • Flash Slideshow Maker is a Flash album creator to make animated photo slide show with SWF file as the output format. It transforms your digital photo collection to Macromedia Flash file format ( SWF ) which you can share your memorial moments with your family or friends on your own homepage, post on your Blog or upload to your own website.
  • Sothink SWF Catcher for IE – is a free and useful extension to Internet Explorer that enables you to save multiple Flash based charts, presentations, e-cards, games and Flash movies in it at one time. The small size allows it embedding in IE by just adding a new button. With only few clicks you can store your favorite Flashes easily.
  • FontRenamer is a tool, that renames truetype font files (*.ttf) to the real name of the typefaces. Simply select a folder of font files and click the Rename button. The program will display a list of the original file name and the renamed name and also offer an option to undo the operation.
  • Digital Image Tool – was created specifically to batch process images quickly, applying flexible resizing methods, rotation, cropping, scaling, watermarking, renaming and more. As a multimedia designer Digital Image Tool has come in very handy?..we made it originally for use in-house but decided to put a little more effort into the program and release it for free to the public.
  • JR Screen Ruler – is an easy to use, small screen ruler that you can use to measure distances on your screen. It supports pixels, centimeters, picas and inches and can be adjusted in length to fit your screen.
  • Quick HTML Color Picker -is a freeware color picker application designed for Windows OS. With Quick HTML Color Picker, you can easily pick any color from the screen. You can preview the color, use mouse or keyboard to select the color you wanted, and get the color in RGB and HTML format.
  • LS Screen Capture – captures your desktop in several handy ways. Capture the entire desktop screen, the entire desktop work area, capture using your mouse by creating a rectangle, capture an entire window, the entire window work area, capture any active window with key stroke (Ctrl + F2).
  • ScreenHunter is a free screen-capture tool for you to easily take screenshots. ScreenHunter can capture a full screen, an active window, the client window, or a rectangular area. It automatically saves captures in BMP or JPEG format, so you don?t have to stop each time you capture, and you can capture as many as you like. It also can save captures to the Clipboard to be copied to other programs, such as Motion Studio and Word. ScreenHunter has a selectable hot-key capture (F1 to F10) and delayed capture, and uses virtually no system resources on standby. ScreenHunter freeware version has no expiration date and can be distributed free of charge.

Selector syntax

A simple selector is either a type selector or universal selector followed immediately by zero or more attribute selectors, ID selectors, or pseudo-classes, in any order. The simple selector matches if all of its components match.

A selector is a chain of one or more simple selectors separated by combinators. Combinators are: whitespace, “>”, and “+”. Whitespace may appear between a combinator and the simple selectors around it.

The elements of the document tree that match a selector are called subjects of the selector. A selector consisting of a single simple selector matches any element satisfying its requirements. Prepending a simple selector and combinator to a chain imposes additional matching constraints, so the subjects of a selector are always a subset of the elements matching the rightmost simple selector.

One pseudo-element may be appended to the last simple selector in a chain, in which case the style information applies to a subpart of each subject.

Rounded Corners

When New WordPress started using this i though you know Internet Explorer is definitely out now when i’m doing some css work that needs rounded corners I’m mostly using only this technique because buyers are ok with it although it’s just for FireFox and Safari. And since most of people still don’t know about this i figured it’s good thing to share.

Of course i’m talking about Border-radius property for FireFox and Safari 3 (only). And here are some nice examples how to use it.

#box { background: #eee; border: 1px solid #ccc; padding: 15px; -moz-border-radius: 10px; -webkit-border-radius: 10px; }

And of course you don’t have to make all corners rounded, it can be just top left etc, so the code goes like this (small not, for example you can’t make rounded corners on images and stuff like that)

* -moz-border-radius-topleft and -webkit-border-top-left-radius
* -moz-border-radius-topright and -webkit-border-top-right-radius
* -moz-border-radius-bottomleft and -webkit-border-bottom-left-radius
* -moz-border-radius-bottomright and -webkit-border-bottom-right-radius

100% height model css?

I had been looking around for a way to accomplish fixed header and footer on a website when scrolling, and somehow i haven’t got it right with background attachment: fixed, neither i got it with absolute position…

I have a main Div called wrapper, inside there are three main Divs: header, content and footer, and each one of them has sub Divs inside for the content of each one. So the structure goes something like this in general terms:

body[

[ Div:wrapper
Div:Header
Div:top-banner
Div:Menu
Div:Buttons
]
[Div:Content]

[Div:Footer
Div:bottom-banner
]
]

is there any way to accomplish that the header and footer remain “locked” at the top and bottom of the browser window and only the content scrolls down.

See Here is the proper solution:

html, body {
height: 100%;
}

body {
any other styles;
}

#container {
min-height: 100%;
other styles;
}
* html #container {height: 100%;}/*IE6*/

this way, your page start out 100% but can grow bigger as content demands.

The benefits of Web Standards to your visitors, your clients and you!

  1. The Web Standards
  2. What are Web Standards about?
  3. A mindset change
  4. Semantically correct markup
  5. What is valid code?
  6. What is accessible code?
  7. Why use CSS to separate content from presentation?
  8. A CSS based site in action
  9. How do your VISITORS benefit from Web Standards?
  10. How do your CLIENTS benefit from Web Standards?
  11. How do YOU benefit from Web Standards?
  12. What are the downsides
  13. How do you achieve Web Standards?
  14. Conclusion
  15. Web Standards resources

Why tables for layout is stupid:

Tables existed in HTML for one reason: To display tabular data. But then border=”0″ made it possible for designers to have a grid upon which to lay out images and text. Still the most dominant means of designing visually rich Web sites, the use of tables is now actually interfering with building a better, more accessible, flexible, and functional Web. Find out where the problems stem from, and learn solutions to create transitional or completely table-less layout.

The problem with using tables:

  • mixes presentational data in with your content.
    • This makes the file sizes of your pages unnecessarily large, as users must download this presentational data for each page they visit.
    • Bandwidth ain’t free.
  • This makes redesigns of existing sites and content extremely labor intensive (and expensive).
  • It also makes it extremely hard (and expensive) to maintain visual consistency throughout a site.
  • Table-based pages are also much less accessible to users with disabilities and viewers using cell phones and PDAs to access the Web.

Modern browsers are much better at rendering Web standards and we don’t need to use these archaic methods any more.

Instead of nesting tables within tables and filling empty cells with spacer GIFs, we can use much simpler markup and CSS to lay out beautiful sites that are faster to load, easier to redesign, and more accessible to everyone.

By using structural markup in our HTML documents and Cascading Style Sheets to lay out our pages, we can keep the actual content of our pages separated from the way they are presented.

This has several advantages over using tables….

Redesigns are easier and less expensive

By removing presentational markup from your pages, redesigns of existing sites and content is much less labor intensive (and much less expensive). To change the layout of the site, all you need to do is change the style sheets; you do not need to edit the pages themselves at all.

Using Web standards reduces the file sizes of your pages, as users no longer need to download presentational data with each page they visit. The Style sheets that control layout are cached by viewers’ browsers.

Reduced file size means faster loads and lower hosting costs.

Using Web standards also makes it extremely easy to maintain visual consistency throughout a site. Since pages use the same CSS document for their layout, they are all formatted the same.

This strengthens your brand and makes your site more usable.

Using Web standards makes our pages much more accessible to users with disabilities and to viewers using mobile phones and PDAs to access the Web.

Visitors using screen readers (as well as those with slow connections) do not have to wade through countless table cells and spacers to get at the actual content of our pages.

In other words, separating content from the way it is presented makes your content device-independent.

Speaking of accessiblity, minimizing your markup and using header tags properly will also help improve your search engine ranking.

Reducing the ratio of code to content, using keywords in your header tags, and replacing header GIFs with actual text will all help your sites get better search engine results.

    IE and width & height issues

    IE has a rather strange way of doing things. It doesn’t understand the min-width and min-height commands, but instead interprets width and height as min-width and min-height – go figure!

    This can cause problems, because we may need boxes to be resizable should more text need to go in them or should the user resize text. If we only use the width and height commands on a box then non-IE browsers won’t allow the box to resize. If we only use the min-width and min-height commands though then we can’t control the width or height in IE!

    This can be especially problematic when using background images. If you’re using a background image that’s 80px wide and 35px high, then you’ll want to make sure that the default size for a box using this image is exactly 80 x 35px. However, if users resize the text then the box size will need to expand gracefully.

    To resolve this problem, you can use the following code for a box with class=”box”:

    .box
    {
    width: 80px;
    height: 35px;
    }

    html>body .box
    {
    width: auto;
    height: auto;
    min-width: 80px;
    min-height: 35px;
    }

    All browsers will read through the first CSS rule but IE will ignore the second rule because it makes use of the child selector command5. Non-IE browsers will read through the second one and will override the values from the first rule because this CSS rule is more specific, and CSS rules that are more specific always override those that are less specific.

    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 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, so as to create a minimum width of 600px:

    #container
    {
    min-width: 600px;
    width:expression(document.body.clientWidth < 600? "600px": "auto" );
    }

    The first command is the regular minimum width command; the second is a short JavaScript command that only IE understands. Do note though, this command will cause your CSS document to invalidate so you may prefer to insert it into the head of each HTML document to get round 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 < 600? "600px" : document.body.clientWidth > 1200? “1200px” : “auto”);
    }

    Verified by MonsterInsights