Chapter 3 Playing with CSS Grid Layout Without Calculation
3.1 Introduction to Grid Layout
3.2 Using Grid Layout
3.2. 1 Terminology
1 术语名 定义 是否涉及HTML标签2 列 内容度量的垂直单位 否3 容器 构成一个网格布局的HTML元素 是4 槽 网格布局中列与列之间的统一留白 否
3.2.3 Fixed grid layout or flowing grid layout
1 // 由于网络用户的屏幕尺寸不一,设计人员有两种选择:2 // 1.要么选择一种对于大多数用户合理的固定布局大小(并且限制这种布局内的内容不溢出);3 // 2.要么实现一种灵活的<strong>流动布局</strong>,让内容自适应用户的屏幕,甚至当浏览器窗口大小改变时也会自适应;
3.3 Using Blueprint
1 // Blueprint把一些通用的对网格布局/段落和表格进行样式修饰的CSS技术打包到一个<strong>框架</strong>中,然后可以在各个项目中通用这个框架;2 // 安装Blueprint3 C:\Users\DELL><strong>gem install compass-blueprint</strong>
3.3.2 Apply Blueprint using Compass
1 // 创建一个基本的Blueprint项目 2 C:\Users\DELL><strong>compass create simple --using blueprint/basic</strong> 3 directory simple/ 4 directory simple/images/ 5 directory simple/sass/ 6 directory simple/sass/partials/ 7 directory simple/stylesheets/ 8 create simple/config.rb 9 create simple/sass/screen.scss10 create simple/sass/partials/_base.scss11 create simple/sass/print.scss12 create simple/sass/ie.scss13 create simple/images/grid.png14 write simple/stylesheets/ie.css15 write simple/stylesheets/print.css16 write simple/stylesheets/screen.css17 18 // 在screen.scss文件生成↓↓↓↓↓↓↓↓↓↓:19 // This import applies a global reset to any page that imports this stylesheet.20 @import "blueprint/reset"; // 默认的Blueprint重置模块;21 22 // To configure blueprint, edit the partials/_base.sass file.23 @import "partials/base"; //<strong> 网格布局设置</strong>;24 25 // Import all the default blueprint modules so that we can access their mixins.26 @import "blueprint"; // 让Blueprint的模块可用;27 28 // Import the non-default scaffolding module.29 @import "blueprint/scaffolding"; //<strong> 引入脚手架</strong>;30 31 // Generate the blueprint framework according to your configuration:32 @include blueprint; //<strong> 生成网格布局</strong>;33 34 @include blueprint-scaffolding; //<strong> 表单和其他Blueprint元件;</strong>
3.3.3 Apply Blueprint without class name using Compass
1 C:\Users\DELL>compass create simple --using blueprint/semantic 2 3 Sass: 4 #container { 5 <strong> @include container; </strong> 6 } 7 CSS: 8 #container { 9 <strong> width: 950px; 10 margin: 0 auto; 11 overflow: hidden; 12 *zoom: 1; </strong>13 }
3.4 Using the 960 grid layout system
1 // 安装960系统; 2 C:\Users\DELL><strong>gem install compass-960-plugin </strong> 3 4 // 创建一个960网格系统的Compass项目 5 C:\Users\DELL><strong>compass create -r ninesixty twelve_col --using 960</strong> 6 directory twelve_col/ 7 directory twelve_col/sass/ 8 directory twelve_col/stylesheets/ 9 create twelve_col/config.rb10 create twelve_col/sass/grid.scss11 create twelve_col/sass/text.scss12 write twelve_col/stylesheets/grid.css13 write twelve_col/stylesheets/text.css
3.5 Handling vertical rhythm via Compass
1 @import "compass/typography"; //<strong> 引入段落模块</strong>;2 $base-font-size:16px; // 声明字体大小;3 $base-line-height:24px;4 <strong>@include establish-baseline; </strong>5 h1 { @include adjust-font-size-to(48px); }
3.5.2 Pre and post
1 //<strong> leader混合器在元素前加一个基线单位的外间距</strong>; 2 //<strong> trailer混合器在元素的后边加了一个基线单位的外间距;</strong> 3 p { @include leader; @include trailer; } 4 Sass: 5 p { 6 @include leader; 7 @include trailer; 8 } 9 CSS:10 p {11 margin-top: 1.5em;12 margin-bottom: 1.5em;13 }
3.6 Summary
1 // 流行的CSS网格框架如何简化维护留白和快速构建原型设计;2 // 通过添加一些CSS类,就可以创建彼此之间有统一间距的竖列内容;
Chapter 4: Compass is no longer boring
// Use Compass to reset the browser's default style ;
// Compass auxiliary to improve style sheet layout;
// Use Compass to create sticky footers/diversified tables and floats;
4.1.1 Global style reset --global-reset
4.1.2 More control with targeted style reset
1 @import "compass/reset/utilities";2 >1.<strong>HTML5样式重置--@include reset-html5 </strong>3 >2.Compass文档中更多的样式重置4 >>1.<strong>reset-box-</strong><strong>model:移除元素的内边距和边框</strong>;5 >>2.<strong>reset-</strong><strong>font:重置文字的字号和基线</strong>;6 >>3.<strong>reset-</strong><strong>focus:移除浏览器提供的轮廓线</strong>;7 >>4.<strong>reset-table和reset-table-</strong><strong>cell:重置表格的边框和对齐方式</strong>;8 >>5.<strong>reset-quotation:为<blockquotes>添加仅存在于样式表中的双引号</strong>;
4.2 Faster and more intuitive typography aids
4.2.1 Link aids
1 >1.<strong>为链接配色</strong>;2 a { @include <strong>link-colors</strong>(#333,#00f,#f00,#555,#f00); }3 >2.<strong>通过hover-link设置悬停样式(设置下划线); </strong>4 a { @include <strong>hover-</strong><strong>link</strong> }5 >3.<strong>通过unstyled-link设置隐性的链接(去掉颜色/光标样式/下划线); </strong>6 p.secret a { @include unstyled-link }
4.2.2 List Auxiliary Tool--Create various lists
1 >1.<strong>用pretty-</strong><strong>bullets装点列表</strong>(利用背景图片显示列表的项目符号) 2 ul.features { 3 @include <strong>pretty-bullets('pretty-bullet.png'); </strong> 4 } 5 >2.通过no-bullet和no-bullets去掉项目符号 6 li.no-bullet { <strong>@include no-bullet</strong> } //<strong> 去掉li类no-bullet的符号;</strong> 7 ul.no-bullet { <strong>@include no-bullets</strong> } //<strong> 去掉整个列表的项目符号;</strong> 8 >3.轻松横向排布 9 // horizontal-list混合器有两个参数:$padding(内边距)和$direction(浮动方向);10 ul.nav { @include <strong>horizontal-</strong><strong>list</strong> } 11 ul.nav { @include <strong>horizontal-</strong><strong>list(7px,right)</strong> } // 列表水平排列;12 >4.用inline-list处理内联列表13 ul.words { @include <strong>delimited-list</strong> } //<strong> 将列表设置成内联的样式;</strong>14 ul.words { @include <strong>delimited-list("!")</strong> } //<strong> 自定义分隔符</strong>;
4.2.3 Text Auxiliary Tool- - Conquer text with auxiliary tools
1 ><strong>1.用省略号代表截断内容</strong>(text-overflow:ellipsis);2 td.dot { <strong>@include ellipsis;</strong> }3 ><strong>2.用nowrap防止文本折行 </strong>4 td { <strong>@include nowrap</strong> }5 >3<strong>.用replace-text将文字替换图片 </strong>6 h1.coffee { <strong>@include replace-text("coffee-header.png")</strong> }
4.3 Layout auxiliary tools
4.3.1 Sticky footer
// Generate a high 40px footer, and always at the bottom;
1 @include sticky-footer { 40px, "#content", "#footer", "#sticky-footer"};
4.3.2 Stretchable element
// Element is positioned absolutely, 5px from the border;
1 // stretch混合器有4个参数:$offset-top/$offset-right/$offset-bottom/$offset-left;2 a.logo { @include stretch(5px,5px,5px,5px) }
4.4 Summary
// In this chapter, we learned about Compass’ time-saving and labor-saving tools;
// Includes: links/lists/text /Layout;
Chapter 5 Using CSS3 with Compass
// Use Compass’ CSS3 module to create a cross-browser CSS3 style sheet
/ / Support some CSS3 features in lower versions of IE
// CSS3 advanced skills in Compass
5.1 new attribute: browser prefix
1 // 引入CSS3模块 2 <strong>@import "compass/css3"; </strong> 3 Sass: 4 .notice { 5 @include border-radius(5px); 6 } 7 CSS: 8 .notice { 9 -moz-border-radius: 5px;10 -webkit-border-radius: 5px;11 border-radius: 5px;12 }
5.2 Using CSS3 with Compass
5.2.1 Rounded corners
1 button.rounded {2 <strong>@include border-radius (5px); </strong>3 }
5.2.2 CSS3 shadow--text-shadow and box-shadow
1 Sass: 2 $shadow-1:rgba(#000,.5) -200px 0 0; 3 $shadow-2:rgba(#000,.3) -400px 0 0; 4 h2 { 5 <strong>@include box-shadow($shadow-1); </strong> 6 <strong>@include text-shadow($shadow-1,$shadow-2); </strong> 7 } 8 CSS: 9 h2 {10 -moz-box-shadow: rgba(0, 0, 0, 0.5) -200px 0 0;11 -webkit-box-shadow: rgba(0, 0, 0, 0.5) -200px 0 0;12 box-shadow: rgba(0, 0, 0, 0.5) -200px 0 0;13 text-shadow: rgba(0, 0, 0, 0.5) -200px 0 0, rgba(0, 0, 0, 0.3) -400px 0 0;14 }
5.2.3 Color gradient
1 #pattern { 2 <strong> @include background( 3 linear-</strong><strong>gradient</strong>( 4 360deg, 5 #bfbfbf 0%, 6 #bfbfbf 12.5% 7 #bfbf00 12.5%, 8 #bfbf00 25%, 9 ...10 )11 );12 width:400px;13 height:300px;14 }
5.2.4 Embed font with @font-face
1 <strong>@include font-face</strong> ("ChunkFiveRegular",2 font-files("ChunkFiveRegular-webfont.woff",woff,3 "ChunkFiveRegular-webfont.woff",ttf, 4 "ChunkFiveRegular-webfont.woff",svg,5 "ChunkFiveRegular-webfont.woff",normal,normal));
5.4 Summary
// Use CSS3 mixer to achieve: Rounded corners/Shadow/Gradient and Text introduction;

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software