Click here to return to the 123WORDPRESS.COM HTML Tutorial section. To view the CSS tutorial, please click here. Above: Markup language – image replacement . Chapter 15 Specifying styles for <body> One of the benefits of separating content from display is flexibility. By controlling the layout of a website with CSS (the method used in Chapter 12), you can control the design elements of the entire website. By changing a few rules, you can dramatically update thousands of pages at once. One of the demonstrations of the convenience of using CSS to control layout is to specify styles for <body>. By adding a class or id to the <body> tag, you can customize any tag on the page. There is no need to worry about repeated definitions. In this chapter, we will explore how to use the same markup structure to switch between two different layout configurations by adding classes to the <body> tag. Two-column or three-column layouts are like when we redesigned the website for Fast Company using CSS layout techniques. One of the challenges is that although all pages share the same navigation and footer area, we also need to create two different layouts. The first layout is the "index page (home page)", see Figure 15-1. This is a page with navigation functions, allowing users to continue to drill down into the directory structure of the website. For these pages, we decided to use a three-column layout. ![]() Figure 15-1 Fast Company's three-column "index page" demonstrates the second page layout, which is the "content page" Figure 15-2. Any page that feels like a destination uses this layout. To improve readability, we decided to omit the left column and leave two columns, that is, one large column for content and the other for advertising. ![]() Figure 15-2 Fast Company's two-column "content page" example. The reason I explain this is not to prove that we have solved a great mystery of page layout, but to demonstrate that adding classes to the <body> tag can adjust the column width and place or omit the third column according to the page form. When creating such an effect, no rules are repeated at all, and no additional style sheets are introduced. Markup and style structure After starting to describe the markup structure shared by the two pages, these descriptions will begin to make sense. In order to achieve a column layout, the absolute positioning method mentioned in Chapter 12 will be used. The simplified markup structure of the content page looks like this:
Use CSS rules to add a right outer patch to #content and #footer that is large enough to fit into #right using absolute positioning. In this example, 190 pixels is just enough.
Index Page For the index page, the markup structure is exactly the same, so there is no need to duplicate the shared CSS rules, but an extra <div> is added to the left of #content as a third column (#left).<div id="header"> ...header info here... </div> <div id="content"> ...content here... </div> <div id="left"> ...left column info... </div> <div id="right"> ...right column info... </div> <div id="footer"> ...footer info... </div> |
<<: Detailed explanation of the difference between JavaScript onclick and click
>>: TCP performance tuning implementation principle and process analysis
mysql 5.6.35 winx64 free installation version con...
Next, we will learn how to monitor server perform...
How to make a simple web calculator using HTML, C...
1. Overview mysql-monitor MYSQL monitoring tool, ...
Whitelist rule syntax: BasicRule wl:ID [negative]...
What I have been learning recently involves knowl...
1. MySQL download address; http://ftp.ntu.edu.tw/...
1. View the current host name [root@fangjian ~]# ...
<br />Original URL: http://www.lxdong.com/po...
1. Design source code Copy code The code is as fol...
Table of contents 1. MHA 1. Concept 2. Compositio...
Operating system: Ubuntu 17.04 64-bit MySQL versi...
Table of contents ESLint plugin installation in H...
Table of contents 1. beforeCreate and created fun...
This article shares the specific code of jQuery t...