How to Create a Webpage with Equal Heights Columns

Опубликовал Admin
21-10-2016, 05:55
593
0
Creating equal height columns in webpages has been a challenge for developers for some time and largely has involved javascript to pull it off. However, this method uses HTML5 and CSS3 techniques to reduce code, but gives you the same effect.

Steps

  1. Create a standard layout using a DOCTYPE, a STYLE, and a DIV with two nested DIVs.
  2. Name your DIVs so that they can be worked on. The first DIV is going to use "id", while the nested DIVs are going to use "class".
  3. Tell CSS how to manipulate these DIVs. You make these style changes within the style tags. Make sure of the "#" and "." in front of the tags. These are important, and without them, everything breaks.
  4. Add some content at this point. It will give you some idea as to how things are going to look as you progress. Add some content to the left and right DIVs.
  5. Preview the page.
    • Not only is this pretty bland, but the DIVs are not properly aligned either. You'll notice that "Right" is under "Left", not to the side of it.
  6. Make some changes to fix this. Change the CSS beginning with the ID, which needs to be treated as a table. Set a width of 80% of the screen and centre align the whole box.
  7. Make sure the two nested DIVs are now treated as table cells. Create a border around the two, so that you can see how this is all going to pan out.
  8. Look at the difference that's made.
  9. Add more text into one of the cells. You'll see that no matter how big the box on the left gets, the box on the right retains the same size as the left one.

Tips

  • The code in this document is simplified, but is completely legal code in HTML5. Most modern HTML5 capable browsers will automatically recognise where things are supposed to go and display correctly. This reduces the amount of code needed to be typed.
  • Always indent nested code. This makes it much easier to see related content and helps you find bugs in your code more quickly.

Warnings

  • Always check, recheck, then triple check your code. A missing semicolon (";") can break everything, and it can be a complete pain to work out what went wrong.
  • "#" in the CSS refers to the ID of an HTML object. A full stop/period (".") in the CSS refers to the Class of an HTML object. The two are not interchangeable so get them right.
Теги:
Information
Users of Guests are not allowed to comment this publication.