search
HomeWeb Front-endHTML Tutorialcompass模块_html/css_WEB-ITnose

 

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

 @import "compass/reset"

Layout :页面布局的控制能力

@import "compass/layout"

只有这两个模块是需要明确 指定引入的
@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

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

require 'compass-normalize'

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

在SCSS文件中引用normalize

@import "normalize";

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"

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

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

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

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

.reset-sec{ @include nested-reset;}

 

 

 

 

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";

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 }

经过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 }

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>

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

 

 

 

 

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 }

生成的代码:

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 }

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

@import "compass/support";

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

控制台命令:

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

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

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

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

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

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

不设置的话 默认支持 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 }

编译之后:

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

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

Lists:列表修饰模块

Text:文本修饰模块

Vertical Rhythm:垂直韵律修饰模块

@import "compass/typography/vertical_rhythm";

 

Statement
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
What is the difference between an HTML tag and an HTML attribute?What is the difference between an HTML tag and an HTML attribute?May 14, 2025 am 12:01 AM

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The Future of HTML: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

See all articles

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

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor