Articles island - a directory of quality articles, free quality articles reprint for your web site and email newsletter.
Free Articles Reprint for Your Web Site, Email Newsletter, Blog, Ezine and RSS Feed.
Submit Your Articles to Our Article Directory for Massive Exposure.
Total Live Articles: 92613  Total Categories: 389



 
  Advanced Search
Articles island Expert Author - Linda C Dipman
I was born in Portsmouth, Virginia, but I have spent most of my life in Kansas. I am a business woman who has run my own upholstery business for over thirty years. I have three married children and six grandchildren. In my spare time, when i'm not entertaining my grandchildren, I like to travel, read, decorate, and of course I love to write. My passion...
Home » Internet-and-businesses-online » Web-development » How To Fix CSS Float Issues

Articles island Expert Author - Sam S.
Author Name:
Sam S.

Country:
United States

Member Since:
24 Oct 2006

Total Live Articles:
22



Email to Friends
Rate this Article
Bookmark this Article
Print this Article
Report this Article
Leave a Comment





How To Fix CSS Float Issues

By: Sam S.
Total views: 21
Word Count: 680
Date:Oct 11th 2007
Article Rating: No Ratings Yet

CSS is great. On somedays I'd go so far as to say it's a lifesaver. But every now and then you'll encounter a CSS issue that will drive you crazy.

In this case we'll talk about two of the more common issues when using the float property to create your layout.

For those of you who're new to CSS, Float is a CSS property that allows you to align your elements, such as DIVs, to create website layouts. The values for Float include Left, Right and None. You can use Floats to align elements and if done properly you can do in such a way that it's dynamic -- almost fluid.

Let's say you need to create an image gallery. Your idea is to place 4 images on each line, but after you place the first image the second image goes to the next line.

I'll admit in the past I used to use negative values to align my images so that the second image would show up next to the first one using the margin-left, right, top, bottom property. I even considered using tables, but opted to use negative values instead. There's nothing wrong with using negative margin property, but not when there's a better solution for it, such as using floats.

If you apply Float to those images then they'll align in one row, then you can continue to add more images using the float property and you wouldn't have to worry about whether they'd line up or not because the float property will recognize that there's too many elements on this line and it will push the images to the next line.

But what if you're using Floats for your website layout, for your divs and not just the images.

There are 2 main issues that you'll face with Floats.

Let's say you have three elements. Parent1(website's main container), Child1(left navigation bar), and Child2(content area). Parent1 is the main div container and your goal is to float the child divs side by side sort of like having a left navigation area and a right content area. Sounds great.

You've set your parent1's height to auto, and you've set child1 and child2's height as auto. But once you open and view it in a webpage the parent element's height is only 1 or 2pixels in height, the child elements seem to look like they're floating above the parent container, and the parent container doesn't seem to recognize the div's height. (see test link 1 on website).

No worries, here is an easy solution for it.

Add overflow:auto; for the CSS of the parent container and it will automatically recognize the floats and will increase in height so that it appears that the floats are part of the parent container just as you wanted. Wow all that in one line.

But don't forget there's still one more Float issue.

The second issue is more of a cross browser compatibility issue with floats, but still as important. If you try to Float for ex: three images to the left and are using margin property, then sometimes the first container that floats will have double the margin in Internet Explorer.

Welcome to the Float Peekaboo Bug / IE Float Doubled Margin Bug.

That's right if you've tried to Float an element and use any kind of margin then you'll notice that it will double the margin in IE.

I'm sure there are some decent hacks, but there's an easy way to fix this in CSS. The Float Margin Killer. In the CSS for that container add display:inline I don't know why but for some reason this property seems to fix the double margin property.

That's it? Yes that's it. Now you can start using floats.

About The Author-- Sam is the founder of Netlyte Houston website Design, A Website Design firm that's geared specifically for building websites for Businesses. Websites that have generated real results such as increase in newsletter sign ups to increase in sales. Plus all of their services are backed by a 100% Guarantee.

Article Source: Articles island - Free article submission and free reprint articles


Most Viewed Web Development Articles




Most Viewed Web Development Articles:

Choosing A Content Management System For Your Website
If you are planning to launch a website, you need to choose the correct Content Management System. Without the...

E-commerce Website Design Guide for Small Business Owners
When a small business owners starts thinking of having his own e-commerce web site he starts looking for relia...

Information is the hottest product on the market!
If you have been researching or involved in online business for very long, you have no doubt seen a multitude ...

Your First HTML Email Form
Creating your first HTML email form is not so simple, here is what you need to know...

How To Send An HTML Newsletter
Who here hasn't tried to create and send an HTML newsletter by email. It sounds easy enough. Create an html p...

Do You Have An Authoritative Website?
What does an authoritative site provide? In one sentence, an incredible amount of original material and a memo...

Who Invented Internet Commerce
Fascinating history of the beginnings and development of internet commerce...

Make Money Online By Making A Website
We have all seen thousands of websites on the Internet. Some are full of useless information and others provid...

Deciphering Website Hosting
Whether you're an entrepreneur thinking about launching a website or a website developer who needs to find a g...

Using Automated Scripts to Improve Web Site Productivity
There are two types of web sites on the Internet. The die hard SEO managers still favor static pages, because ...


Recent Web Development Articles




Recent Web Development Articles:

website development in UK and London
To solve your business problems by understanding your business goals and strategic & marketing objectives# To ...

Traffic, Traffic and More Traffic
There are many reasons why people visit some websites frequently than others. Increase your website’s traffi...

The Secret to Using the Word Free In Your Online Promotions
Free is a magic word. There's nothing that rings in people's ears more than the word free. Let's face it, ever...

The Secret to Effectively Generate Website Traffic
Starting a business or wanting to provide a service to a lot of people can be challenging. The first obstacle ...

Low-Cost Website Traffic Building
Increasing website traffic involves setting aside a definite number of hours in a day to promote the business....

Secret To Using Press Release To Generate Huge Traffic
Are you getting ready to introduce a new service or product? Have you used or are you familiar with press rele...

Perpetual Traffic Generation Tips
For people engaged in web hosting, e-commerce or online marketing maintaining industry, traffic is just one th...

How To Start an Online Traffic Virus Today
If you are working on a web hosting industry and are thinking about how it works, this article is for you....

How To Quickly And Easily Start A Traffic Virus
Traffic should be your number one concern when establishing your website. Success to building and promoting yo...

How to Get Unlimited Traffic Forever!
The digital age has given people a new way of doing business. This is because it is accessible to a lot of peo...

Most Viewed Articles by Sam S.




Most Viewed Articles by Sam S.:

How To Send An HTML Newsletter
Who here hasn't tried to create and send an HTML newsletter by email. It sounds easy enough. Create an html p...

How To Create An HTML Newsletter
Turn that Newsletter Webpage into an html email newsletter. You'll find out how to format the newsletter so t...

Deciphering Website Hosting
Whether you're an entrepreneur thinking about launching a website or a website developer who needs to find a g...

How To Fix CSS Float Issues
There are 2 CSS Float issues that tend to crop up during website design and testing - the object floating outs...

How To Use Graphics and Color in Web Design
The human psyche is dependent upon several factors; but one common thing that attracts every person is pomp an...

How Do I Start Designing A Website?
If you have decided on designing your website, then there are a few important things you need to keep in mind ...

Website Designing for Your Company's Identity
While designing your site, always remember that there will be a large majority if not all who might not know a...

Does Your Website Have a Call To Action?
What is your company's website aiming for? Well, definitely as an entrepreneur your main aim is to sell the pr...

Deciphering Website Design - WebProgramming, Databases & AJAX
Ever wonder how website design and development technologies work together to create stunning websites? Here's ...

How To Use Advertising to Boost Traffic For Your Website
This is a common problem faced by most small business enterprises. They invest a lump sum behind advertisement...

You have permission to publish or reprint this article in your ezine, website, blog, forum, RSS feed or print publication, free of charge. As long as you keep this article with no changes(included Article Title, Article Body, Author Name, Article Source and keep all links in this article active)and you agree to our publisher terms of service. Below are ready HTML code for this article, you can copy and paste directly into your web page.

How To Fix CSS Float Issues -- HTML Version:


How To Fix CSS Float Issues -- Summary:

How To Fix CSS Float Issues -- Keywords:
1   2   3 Good!   4   5   6 Very Good!!   7   8   9   10 Excellent!!!  
Comments:
No Comment Posted.

Leave Comment: Please Login to leave a comment. Not a member yet? Sign Up now.