Using CSS to Fix Anything

Posted: January 24, 2014 in Uncategorized

I was on and found this and thought it would be helpful later down the line in class.
Credit of

NOTE: Due to the fact that this is a longer article I have used the more option in the text tab in wordpress.


Jun 152008

Using CSS to Fix Anything: 20+ Common Bugs and Fixes


Without a doubt, a logical and structured layout is the best way to go. Not only because your layout varies between browsers, but also because CSS has a lot of ways to position every element you have. Today we wanted to share with you some quick tips on how to avoid easy pitfalls when creating your CSS layout.

This is the first part in this series as there are SO MANY good tricks out there and if you see an easier or better methods, then post a comment below or email me. I will do my best to include it in our next post in this series.

You might be interested to check our other related post for some inspiration:

IE Bug Fixes

1- Bug Fix: IE Double Margin Float Bug– It’s an Internet Explorer-exclusive bug wherein an element that is floated – and given a margin in the same direction as the float – ends up with twice the specified margin size. The fix is extremely simple. All you have to do is apply a display: inline rule to your floated element. So you simply go from something like this:

#content {
    float: left;
    width: 500px;
    padding: 10px 15px;
    margin-left: 20px; }

To something like this:

#content {
    float: left;
    width: 500px;
    padding: 10px 15px;
    margin-left: 20px; 

CSS Tips

2-Overcoming the Box Model Hack– If you want to specify a width to any div, do NOT specify padding or margins. Just create an inner div with no width set and specify its padding and margins instead. So instead of doing this:

width: 150px;
border: 5px;
padding: 20px;

Do something like this:

width: 150px;
#main-div div{
border: 5px;
padding: 20px;

3-Min-height attribute ignored in IE–  “min-height” attribute works well in Firefox but IE ignores it. IE’s height act as FF’s min-height. Note: in IE 7 problem was fixed.

/* for understanding browsers */
.container {
border:1px solid #000;
/* for Internet Explorer */
* html .container {
height: 8em;

4- Min-Width for IE -A fix for the lack of min-width in Internet Explorer.

Centering a Block Element

5-Centering Block Element–  There are multiple techniques for centering a block element; and the choice for the technique depends on whether you have the size set in percentages or in more absolute values.

Centering an entire page’s contents:

text-align: center;
text-align: left;
width: 960px;
margin: 0 auto;

6-Vertical Align with CSS–  If you want to know how you can achieve vertical-align functionality the right way, simply specify the line-height for your text the same height as that of the container’s.

#wrapper {
	background:url(container.gif) no-repeat left top;
	padding:0px 10px;
#wrapper p {

Column Issues

7- Top reasons your CSS columns are messed up– An easy-to understand article on how to fix common CSS Column issues with helpful diagrams and code snippets.

CSS Tips

8- The Expanding Box Bug-When you try to create a two-column float layout, IE will create a “float drop”, and it’s caused by having over-sized content in a fixed-width floated div that must fit into a particular spot in the layout. Several possible workarounds are detailed in this post.

CSS Tips

CSS Positioning

9- Understanding CSS Positioning part 1– An interesting series of articles that doesn’t only cover positioning, but also properties that define layout such as display and float, and a preview of the new CSS3 layout modules. The first part will introduce the positioning and display property. Part1, Part2, Part3 gives you a deep understanding of the possibilities you have in positioning.

CSS Tips

10- What is the difference between relative and absolute positioning?– Whether to use relative or absolute positioning can be extremely frustrating to people just getting started with CSS. The answer to this question will add a bit of clarity to this confusion.

position: relative;
bottom: 40px;
right: 40px;

To get this:

CSS Tips

11-HangTab– Create a Sticky Tag from the Edge of the Browser Window (Even with Centered Content). Check out Panic’s website for their software Coda.

#hang_tab {
position: absolute;
top: 7px;
left: 0px;
width: 157px;
height: 93px;

CSS Tips

CSS Float Concept

12- CSS Float Theory: Things You Should KnowSmashingMagazine browsed through dozens of related articles and selected the most important things you should keep in mind developing css-based layouts with floats.

<div> <!-- float container -->
<div style="float:left; width:30%;"><p>Some content</p></div>
<p>Text not inside the float</p>
<div style="clear:both;"></div>

13- Floatutorial: Simple tutorials on CSS Floats– Floatutorial takes you through the basics of floating elements such as images, drop caps, next and back buttons, image galleries, inline lists and multi-column layouts.

CSS Tips

14- Clear Your Floats – The Right Way– Float clearing can be one of the most frustrating aspects of CSS development, one of the best ways is to use the EasyClearing on your site.

/* EasyClearing */
	content: ".";
	display: block;
	height: 0;
	clear: both;
	visibility: hidden;

{display: inline-block;}

/* Hides from IE-mac \*/
* html #container
{height: 1%;}

{display: block;}
/* End hide from IE-mac */

CSS Tips

Easier Rounded Corner Solutions

15- Mike asks the CSS Guy for recommendations on rounded corners– “Simplest way is to use a giant gif, then I’ll markup my box”

  <p>beautifully-encapsulated paragraph</p>

“And give it the background”

.roundBox {
  background:transparent url(roundBox.gif) no-repeat top left;
.roundBox .boxBottom {
  background:white url(roundBox.gif) no-repeat bottom left;
  margin:0 -20px -20px -20px;

Also Askthecssguy explains the technique used in Google Analytics, which works by leaving a 1px notch in every corner to get the rounded corner effect which is a new way of creating rounded corners without using static images. You can see an example here.

CSS Tips

16-3 Simple Steps in Coding a Rounded Corners Layout– Alen Grakalic’s approach to coding a fixed width, rounded corners layout in 3 simple steps. He also created a demo here.

CSS Tips

CSS Form Issues

17- Tips For Creating Great Web Forms– Cris Coyer shares with us some tips for floating labels, :focus Pseudo Class, using hints and more. He also created the Nice & Simple Contact Form, which he first posted about here.

label {
	float: left;
	text-align: right;
	margin-right: 15px;
	width: 100px;

CSS Tips

18- Clean and pure CSS FORM design– For CSS lovers, this tutorial illustrates a proposal about how to design a pure CSS form without using html tables. You can grab the code here.

CSS Tips

19-Autopopulating text input fields with JavaScript– Sometimes we need to explain to users what they are supposed to enter into text input fields. One common workaround when no label can be displayed is to put some placeholder text in the text field and let that act as the label. This tutorial introduces a nice solution, with JavaScript enabled, the label element is hidden and the value of the input element’s title attribute is copied to the value attribute. If JavaScript is disabled, the label is displayed above the text input, which is left empty. A simple demo, where you can see this in action is here.

CSS Tips

Worth checking CSS Tricks

20- Cross browser Horizontal Rule with Background Image– You’d like to create a cross-browser horizontal rule that utilizes a custom image as the content separator. {
background: #fff url(myhrimg.gif) no-repeat scroll center; 
height: 10px
} hr {
display: none

Your tag should look like this:

<div><hr /></div>

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s