Explain the Full Width CSS Layout

104 15

    Units of Measurement

    • CSS uses different measurements for describing width. The most common measurements used in CSS are pixels, designated with "px," and percentages, designated with "%." Pixels are static -- 100 pixels is 100 pixels across all platforms, regardless of the user's resolution -- while percentages are flexible. Pixels allow the designer to control the appearance of a website, but percentages make the website accessible to all users.

    Using Pixels

    • When using pixels, the definition of "full width" varies from resolution to resolution. According to StatCounter, the most common resolution worldwide is 1024 by 768. A website that makes all parent elements 1024 in width could be considered a "full-width" CSS layout, but only for screens with a 1024 by 768 resolution. In North America, the most common resolution is 1280 by 800; on these computers, the "most common" layout wouldn't reach the full width of the screen.

    Using Percentages

    • Percentages should be used when creating a full-width layout that adjusts itself automatically on all machines. Websites that use percentages are fluid, changing according to the visitor's resolution; 10 percent could equal 80 pixels on one screen and 136 on another. To make a full-width layout in CSS, use "100%" when assigning width to parent elements that are meant to stretch across the entire page. For example, to make a header that stretches across the full width of the monitor, you might put the following into your code:

      <style>
      .header { width: 100%; }
      </style>

      Then, in your HTML, you'd put "<div class="header">.

    Eliminating Margins

    • Margins are additional white space that surround the top, bottom, right and left side of a page or document. Margins are used to make pages easier to read and should be used in the majority of cases. However, if you want a layout that really uses the entire width of the window, you can put the following in between the "<style>" tags in your CSS code:

      body { margin: 0px; }

      The above code zeroes out the margins on all sides of the Web page.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.