Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts...
-
Upload
hubert-grant -
Category
Documents
-
view
215 -
download
0
Transcript of Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts...
![Page 1: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/1.jpg)
Layout with Styles
Castro Chapter 11
![Page 2: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/2.jpg)
Tables vs. CSS
You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or CSS.
However, CSS styles can be updated in a central location and consequently affect changes across your entire site. This cannot be accomplished with tables.
Additionally, CSS separates formatting & style rules from the content of your page.
![Page 3: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/3.jpg)
Structuring Your Pages
Divide your page into logical sections using the <div> tag(ex: “header”, “main”, “footer”)
Place your content in the order that would be most useful if CSS were not used.
Use header elements (h1, h2,…) consistently throughout your pages.
![Page 4: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/4.jpg)
Structuring Your Pages (2)Window document body div “header” div “main” div “footer”
![Page 5: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/5.jpg)
The Box Model
Every element has an invisible box around it.
The invisible box has four parts to it:• Content area
• Padding
• Border
• Margin
![Page 6: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/6.jpg)
The Box Model Examples
W3C Box Model Specifications
ILoveJackDaniels.com (Simplified Model)
HicksDesign 3D Box Model
![Page 7: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/7.jpg)
Positioning With CSSWe can leverage the power of CSS to help us position our
elements in our pages.
4 Ways to Position an Element Box1. Static: leaves the box where it is found in the flow of the
page.2. Absolute: places the box exactly where you want it on the
page with respect to its parent.3. Fixed: place the box in a fixed location in the browser
window.4. Relative: places the box relative to its natural position.
Z-Index: determines the stacking order of overlapping boxes.
![Page 8: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/8.jpg)
Changing Backgrounds
We can change the backgrounds of our boxes. The following CSS rule creates a background image of an avacado that does not repeat and will always appear at the top left corner of the screen. The background color of the page is green.
![Page 9: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/9.jpg)
Setting Box Width / Height
The code below sets the “main” division to a width and height of 90% of a browser’s window. As a user resizes the browser window the “main” division will stretch.
![Page 10: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/10.jpg)
Setting Margins
The code below demonstrates several possible options for setting the margins around a box. Note: the value must be set in clockwise order (top, right, bottom, left).
![Page 11: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/11.jpg)
Setting Padding
The code below demonstrates several possible options for setting the padding around a box. Note: the value must be set in clockwise order (top, right, bottom, left).
![Page 12: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/12.jpg)
Absolute Positioning
Places your box anywhere on a page you choose, with respect to its parent.
![Page 13: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/13.jpg)
Fixed Positioning
Places your box at a fixed location on the page. As a user scrolls through your page, the image does not move from its affixed location. The following code forces content to stay at the top left corner of the browser.
![Page 14: Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.](https://reader036.fdocuments.net/reader036/viewer/2022082713/5697bf871a28abf838c88b2c/html5/thumbnails/14.jpg)
Float Positioning
Forces your box to the right or left of your text (and other elements) on your page.