Home Web Front-end HTML Tutorial compass模块_html/css_WEB-ITnose

compass模块_html/css_WEB-ITnose

Jun 24, 2016 am 11:32 AM

 

Compass核心模块
Reset :重置CSS模块

 @import "compass/reset"
Copy after login

Layout :页面布局的控制能力

@import "compass/layout"
Copy after login

只有这两个模块是需要明确 指定引入的
@import "compass"默认包含了其他五大模块却不包含resrt,layout

其他四个功能模块和Browser support模块
CSS3:跨浏览器的CSS3能力
Helpers:内含一系列的函数,跟SASS的函数列表很像,比较少用,功能确实丰富强大
Typography:修饰我们的文本样式,垂直韵律
Utilities:没有办法放到其他模块的内容都可以放到这个模块里。辅助工具类模块,helpers都是函数,utilities多是mixin
Browser:配置compass默认支持哪些浏览器。对于特定浏览器默认支持到哪个版本。一个修改将影响六个模块的输出。不同的浏览器做不同的适配。

Compass核心模块概述&Reset模块

compass-normalize插件命令安装:

gem install compass-normalize
Copy after login

引入compass-normalize插件
config.rb文件里:

require 'compass-normalize'
Copy after login

扩展:
config.rb文件里的import-once解决了多次@import同一个文件,compass也只会插入一次被引入问件。但使用了import-once万一遇到真的遇到一个文件必须被引入两次的情况,可以通过被引入文件的文件名的后面加一个感叹号!方式来告知compass这里需要重复引入。@import "compass/reset!"

在SCSS文件中引用normalize

@import "normalize";
Copy after login

Normalize核心模块:
base:用来统一HTML和body标签的字体,文字大小调整、边距等等。
html5:统一html5中新增的元素的展现形式
links:统一a便签的样式修饰,去掉hover和active时候的边线。
typography:统一b、strong、sub、sup等段落文本的样式修饰。
embeds:统一img,svg等标签的样式修饰(比如统一img标签的border为0 )
groups:统一figure、pre、code等标签的样式
forms:统一form相关的button、input、等标签的样式
tables:统一table相关的table、td、th等标签的样式

引入(通过子路径的方式):

@import "normalize-version"//--在引入子类之前需要引入normalize-version@import "normalize/base"
Copy after login

@import "compass/reset/untlities"; .....引入这些mixin的集合

@import "compass/reset"; 其实就是引入了compass/reset/untlities,然后调用了其中的一个global-reset();的mixin集合。

@import "compass/reset/untlities";include global-reset();
Copy after login

reset Utilities核心mixin
http://compass-style.org/reference/compass/reset/utilities/
nested-reset:只用于重置我们页面上的某个选择器下的所有元素。
例如重置reset-sec的所有元素:

.reset-sec{ @include nested-reset;}
Copy after login

Layout模块(使用率最低的模块)
layout模块下面又细分3个核心mixin模块,可以分别引入。

1 @import "compass/layout";2 @import "compass/layout/grid-background";3 @import "compass/layout/sticky-footer";4 @import "compass/layout/stretching";
Copy after login

stretching模块,按父元素尺寸拉伸元素,示例:

1 .stretch-full {2  @include stretch();3 }4 .stretch-full2 {5  @include stretch(5px,0px,5px,5px); //非0值单位px不可省6 }7 .stretch-full3 {8  @include stretch($offset-top:5px,$offset-right:0px,$offset-bottom:5px,$offset-left:5px); //参数顺序可变,非0值单位px不可省9 }
Copy after login

经过sass转换后代码:

 1 .stretch-full { 2  position: absolute; 3  top: 0; 4  bottom: 0; 5  left: 0; 6  right: 0; 7 } 8 .stretch-full2 { 9  position: absolute;10  top: 5px;11  bottom: 0;12  left: 5px; right: 5px;13 }14 .stretch-full3 {15  position: absolute; 16  top: 5px;17  bottom: 5px;18  left: 5px; right: 0px;19 }
Copy after login

sticky-footer模块,提供footer总在页面最底部的解决方案,需要固定的结构:

1 <body>2     <div id="root">3         <div id="root_footer"></div>4     </div>5     <div id="footer">6  Footer content goes here.7     </div>8 </body>
Copy after login

@include sticky-footer(54px) //参数为footer高度@include sticky-footer(54px, "#my-root", "#my-root-footer", "#my-footer") // 自定义选择器
Copy after login

CSS3模块&Browser Support模块(主动使用率较高的模块)
在用CSS3模块的时候要调整Browser Support模块的配置,即使不主动调整CSS3也引入了Browser Support模块。CSS3模块主要用于跨浏览的CSS3的能力。
例:

1 @import "compass/css3";2 .webdome-sec{3  @include box-shadow(1px 1px 3px 2px #cfcecf);4 }
Copy after login

生成的代码:

1 .webdemo-sec {2  -moz-box-shadow: 1px 1px 3px 2px #cfcedf;3  -webkit-box-shadow: 1px 1px 3px 2px #cfcedf;4  box-shadow: 1px 1px 3px 2px #cfcedf;5 }
Copy after login

假如不需要自动生成Firefox的适配代码,这时就需要用Browser Support模块。来配置compass默认支持哪些浏览器。对于特定浏览器支持到哪个版本。Browser Support模块一但修改将影响其余六个模块的输出。
引入support:

@import "compass/support";
Copy after login

引入了CSS3模块,相当于间接引入了support模块。
查看当前支持的浏览器版本:

控制台命令:

1 compass interactive //进入一个用于测试Compass中SassScript的控制台2 browsers() //查看支持的浏览器3 browser-versions(chrome) //查看支持的chrome版本
Copy after login

在sass文件中输入 @debug browsers() 控制台也会打印出支持的浏览器。
设置compass支持的浏览器:

@import "compass/css3";$supported-browsers: chrome firefox;
Copy after login

也可以写成: $supported-browsers: chrome,firefox ; 浏览器队列用 空格或者逗号分隔均可。

设置compass支持的浏览器的最低版本(compass默认支持到ie5.5):

$browser-minimum-versions:("ie":"8","":"")
Copy after login

不设置的话 默认支持 browsers-versions 返回的的版本。
Animation:CSS3动画相关的特性。
Appearance:CSS3的appearance属性,也是CSS3的新规范中新定义的新属性。(还没有一个主流的浏览器支持这个属性)
Background ClipBackground OriginBackground Size:CSS3新增的background相关的属性,用来规定背景的绘制区域、背景图像的定位原点、背景图像的尺寸等。
Border Radius:边框圆角属性
BoxBox Shadow
Box Sizing:用来修改盒模型的宽高的度量方式。
CSS Regions:控制内容布局的新方式
CSS3 Pie:尽可能提高ie浏览器呈现许多CSS3功能
Columns:CSS3的多列布局属性
Filter:主要用于在图片上实现一些特效
Flexbox:(移动端web开发用的比较多)
Font Face:不依赖于用户计算机上安装好的字体,指定下载好的某一种字体
Hyphenation:如何断字换行
Images:CSS3新增了这种生成渐变图形的方式,images用于需要使用这两种方式充当图片的场景。
Inline Block:实现跨浏览器的display:inline-block;能力
Opacity:透明属性,为了兼容低版本的IE
Selection:使用CSS3的selection伪元素定义被选中文本的颜色和背景色
Shared Utilities:想贡献CSS3模块的相关compass插件会用到。工具类模块
Text Shadow:文字阴影属性
TransformTransition:变幻动画属性
User Interface:限制某一区域是否允许鼠标拖拽选择,input元素在无填写状态下提示语的样式

Typography模块
分为四个模块:
Links:链接修饰模块正常态下去掉下划线,在hover的情况下才显示这个下划线hover-link();

1 a{2  @include hover-link();3 }
Copy after login

编译之后:

1 a {2  text-decoration: none;3 }4 a:hover, a:focus {5  text-decoration: underline;6 }
Copy after login

修改不同状态下超链接的颜色link-colors
抹平超链接样式,和他跟父容器的文本无异unstyled Link

Lists:列表修饰模块

Text:文本修饰模块

Vertical Rhythm:垂直韵律修饰模块

@import "compass/typography/vertical_rhythm";
Copy after login

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1274
29
C# Tutorial
1256
24
HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 18, 2025 am 12:09 AM

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, CSS, and JavaScript: Web Development Trends The Future of HTML, CSS, and JavaScript: Web Development Trends Apr 19, 2025 am 12:02 AM

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 Future of HTML: Evolution and Trends in Web Design The Future of HTML: Evolution and Trends in Web Design Apr 17, 2025 am 12:12 AM

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.

HTML: Building the Structure of Web Pages HTML: Building the Structure of Web Pages Apr 14, 2025 am 12:14 AM

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 vs. CSS vs. JavaScript: A Comparative Overview HTML vs. CSS vs. JavaScript: A Comparative Overview Apr 16, 2025 am 12:04 AM

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.

HTML vs. CSS and JavaScript: Comparing Web Technologies HTML vs. CSS and JavaScript: Comparing Web Technologies Apr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML: Is It a Programming Language or Something Else? HTML: Is It a Programming Language or Something Else? Apr 15, 2025 am 12:13 AM

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

What is the difference between <strong>, <b> tags and <em>, <i> tags? What is the difference between <strong>, <b> tags and <em>, <i> tags? Apr 28, 2025 pm 05:42 PM

The article discusses the differences between HTML tags , , , and , focusing on their semantic vs. presentational uses and their impact on SEO and accessibility.

See all articles