CSS3入门
CSS3
CSS3 is the latest evolution of the Cascading Style Sheets language and aims at extending CSS2.1. It brings a lot of long-awaited novelties(备受期待的新特性), like rounded corners, shadows, gradients, transitions or animations, as well as new layouts like multi-columns, flexible box or grid layouts.(圆角,阴影,渐变,渐变,过渡,动画和新的布局多栏,弹性盒子,网格布局)
Experimental parts are vendor-prefixed and should either be avoided in production environments, or used with extreme caution as both their syntax and semantics can change in the future.
CSS3 Modules
CSS3 has been split into "modules".(这些模块彼此独立, 按照各自的进度来进行标准化) It contains the "old CSS specification" (which has been split into smaller pieces). In addition, new modules are added.
Some of the most important CSS3 modules are:
- Selectors
- Box Model
- Backgrounds and Borders
- Image Values and Replaced Content
- Text Effects
- 2D/3D Transformations
- Animations
- Multiple Column Layout
- User Interface
Most of the new CSS3 properties are implemented in modern browsers.
一些新增的CSS3属性
border-radius
IE9+
border-image
<'border-image-source'> || <'border-image-slice'> [ / <'border-image-width'> | / <'border-image-width'>? / <'border-image-outset'> ]? || <'border-image-repeat'>
CSS3 Backgrounds
background-image
给同一个元素增加多个背景图片
CSS3 allows you to add multiple background images for an element
background-size
The CSS3 background-size property allows you to specify the size of background images.
Before CSS3, the size of a background image was the actual size of the image. CSS3 allows us to re-use background images in different contexts.
The size can be specified in 1: lengths, 2: percentages, or by using one of the 3: two keywords: contain or cover.
stretch: 把图片宽高都让其与容器适应
cover 某一边适应容器,而另一边被切割
contain 看电影一样会留下黑边
background-origin
The CSS3 background-origin property specifies where the background image is positioned.
The property takes three different values:
- border-box - the background image starts from the upper left corner of the border
- padding-box - (default) the background image starts from the upper left corner of the padding edge
- content-box - the background image starts from the upper left corner of the content
background-clip
The CSS3 background-clip property specifies the painting area of the background.
The property takes three different values:
- border-box - (default) the background is painted to the outside edge of the border
- padding-box - the background is painted to the outside edge of the padding
- content-box - the background is painted within the content box
CSS3 Colors
CSS supports color names, hexadecimal and RGB colors.
In addition, CSS3 also introduces:
- RGBA colors #p1 {background-color: rgba(255, 0, 0, 0.3);}
- HSL colors #p1 {background-color: hsl(120, 100%, 50%);}
- HSLA colors #p1 {background-color: hsla(120, 100%, 50%, 0.3);}
- opacity #p1 {background-color:rgb(255,0,0);opacity:0.6;}
CSS3 Gradients(IE10+)
CSS3 gradients let you display smooth transitions between two or more specified colors.
Earlier, you had to use images for these effects. However, by using CSS3 gradients you can reduce download time and bandwidth usage. In addition, elements with gradients look better when zoomed, because the gradient is generated by the browser.
CSS3 Shadow Effects
With CSS3 you can add shadow to text and to elements.
In this chapter you will learn about the following properties:
text-shadowbox-shadow
text-shadow(IE10+)
The CSS3 text-shadow property applies shadow to text.
In its simplest use, you only specify the horizontal shadow (2px) and the vertical shadow (2px):
box-shadow(IE9+)
The CSS3 box-shadow property applies shadow to elements.
CSS3 Text
CSS3 contains several new text features.
In this chapter you will learn about the following text properties:
text-overflowword-wrapword-break
text-overflow
The CSS3 text-overflow property specifies how overflowed content that is not displayed should be signaled to the user.
text-overflow: clip ellipsis "string"
word-wrap
允许长单词换行到下一行. 允许长单词被拦腰打断转换到另一行
word-break
The word-break CSS property is used to specify whether to break lines within words.
word-break: normal;
word-break: break-all;
word-break: keep-all;
Web Fonts
CSS3 Web Fonts(在线字体) - The @font-face Rule
Web fonts allow Web designers to use fonts that are not installed(没有安装在用户计算机上的) on the user's computer.
When you have found/bought the font you wish to use, just include the font file on your web server, and it will be automatically downloaded to the user when needed.
Different Font Formats
TTF OTF WOFF WOFF2.O SVG Fonts/Shape EOT
SVG Fonts/Shape:SVG fonts allow SVG to be used as glyphs when displaying text.
例子:
@font-face {
font-family: myFirstFont;
src: url(sansation_light.woff);
}
div {
font-family: myFirstFont;
}
CSS3 Transforms
CSS3 transforms allow you to translate, rotate, scale, and skew(移动,旋转,缩放,拉伸) elements.
A transformation is an effect that lets an element change shape, size and position(形状,大小,位置).
CSS3 supports 2D and 3D transformations.
2D Transforms(IE10+)
translate()rotate()scale()skewX()skewY()matrix()
2D Transform Methods
| Function | Description |
|---|---|
| matrix(n,n,n,n,n,n) | Defines a 2D transformation, using a matrix of six values |
| translate(x,y) | Defines a 2D translation, moving the element along the X- and the Y-axis |
| translateX(n) | Defines a 2D translation, moving the element along the X-axis |
| translateY(n) | Defines a 2D translation, moving the element along the Y-axis |
| scale(x,y) | Defines a 2D scale transformation, changing the elements width and height |
| scaleX(n) | Defines a 2D scale transformation, changing the element's width |
| scaleY(n) | Defines a 2D scale transformation, changing the element's height |
| rotate(angle) | Defines a 2D rotation, the angle is specified in the parameter |
| skew(x-angle,y-angle) | Defines a 2D skew transformation along the X- and the Y-axis |
| skewX(angle) | Defines a 2D skew transformation along the X-axis |
| skewY(angle) | Defines a 2D skew transformation along the Y-axis |
transform:translate()
The translate() method moves an element from its current position (according to the parameters given for the X-axis and the Y-axis).
transform:rotate()
2D 的旋转
The rotate() method rotates an element clockwise or counter-clockwise(逆时针) according to a given degree.
transform:scale()
The scale() method increases or decreases the size of an element (according to the parameters given for the width and height).
transform:skewX()
The skewX() method skews an element along the X-axis by the given angle.
transform:skewY()
The skewY() method skews an element along the Y-axis by the given angle.
transform:skew()
The skew() method skews an element along the X and Y-axis by the given angles.
transform: matrix()
The matrix() method combines all the 2D transform methods into one.
The matrix() method take six parameters, containing mathematic functions, which allows you to rotate, scale, move (translate), and skew elements.
The parameters are as follow: matrix(scaleX(),skewY(),skewX(),scaleY(),translateX(),translateY()):
transform-origin
Allows you to change the position(位置) on transformed elements
CSS3 3D Transforms
CSS3 allows you to format your elements using 3D transformations.
CSS3 Transform Properties
The following table lists all the 3D transform properties:
| Property | Description |
|---|---|
| transform | Applies a 2D or 3D transformation to an element |
| transform-origin | Allows you to change the position on transformed elements |
| transform-style | Specifies how nested elements are rendered in 3D space |
| perspective | Specifies the perspective on how 3D elements are viewed |
| perspective-origin | Specifies the bottom position of 3D elements |
| backface-visibility | Defines whether or not an element should be visible when not facing the screen |
transform-style
transform-style: flat|preserve-3d|initial|inherit;
perserve-3d Specifies that child elements will preserve its 3D position
3D Transform Methods
| Function | Description |
|---|---|
| matrix3d (n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n) |
Defines a 3D transformation, using a 4x4 matrix of 16 values |
| translate3d(x,y,z) | Defines a 3D translation |
| translateX(x) | Defines a 3D translation, using only the value for the X-axis |
| translateY(y) | Defines a 3D translation, using only the value for the Y-axis |
| translateZ(z) | Defines a 3D translation, using only the value for the Z-axis |
| scale3d(x,y,z) | Defines a 3D scale transformation |
| scaleX(x) | Defines a 3D scale transformation by giving a value for the X-axis |
| scaleY(y) | Defines a 3D scale transformation by giving a value for the Y-axis |
| scaleZ(z) | Defines a 3D scale transformation by giving a value for the Z-axis |
| rotate3d(x,y,z,angle) | Defines a 3D rotation |
| rotateX(angle) | Defines a 3D rotation along the X-axis |
| rotateY(angle) | Defines a 3D rotation along the Y-axis |
| rotateZ(angle) | Defines a 3D rotation along the Z-axis |
| perspective(n) | Defines a perspective view for a 3D transformed element |
rotateX(),rotateY(),rotateZ()
3D旋转,围绕空间的3D坐标
perspective
好吧,CSS3 3D transform变换,不过如此! 原理演示网站
Set the perspective(视点) from where an element is viewed
Transitions(过渡效果IE10+)
CSS3 transitions allows you to change property values smoothly (from one value to another), over a given duration.
| transition | A shorthand property for setting the four transition properties into a single property |
| transition-delay | Specifies a delay (in seconds) for the transition effect |
| transition-duration | Specifies how many seconds or milliseconds a transition effect takes to complete |
| transition-property | Specifies the name of the CSS property the transition effect is for |
| transition-timing-function | Specifies the speed curve of the transition effect |
transition: property duration timing-function delay;
Animations(动画)
CSS3 animations allows animation of most HTML elements without using JavaScript or Flash!
What are CSS3 Animations?
An animation lets an element gradually change from one style to another.
You can change as many CSS properties you want, as many times you want.
To use CSS3 animation, you must first specify some keyframes for the animation.
Keyframes hold what styles the element will have at certain times.
The following table lists the @keyframes rule and all the animation properties:
| Property | Description |
|---|---|
| @keyframes | Specifies the animation code |
| animation | A shorthand property for setting all the animation properties |
| animation-delay | Specifies a delay(延迟) for the start of an animation |
| animation-direction | Specifies whether an animation should play in reverse direction or alternate cycles |
| animation-duration | Specifies how many seconds or milliseconds an animation takes to complete one cycle |
| animation-fill-mode | Specifies a style for the element when the animation is not playing (when it is finished, or when it has a delay) |
| animation-iteration-count | Specifies the number of times an animation should be played |
| animation-name | Specifies the name of the @keyframes animation |
| animation-play-state | Specifies whether the animation is running or paused |
| animation-timing-function | Specifies the speed curve of the animation |
animation: name duration timing-function delay iteration-count direction;
animation-direction: normal|alternate;
animation-direction 属性定义是否应该轮流反向播放动画。
CSS Images
Rounded Images
Use the border-radius property to create rounded images:
Thumbnail Images
Use the border property to create thumbnail images.
Responsive Images(响应式)
Responsive images will automatically adjust(自动调整) to fit the size of the screen.
Center an Image
To center an image within the page, use margin: auto; and make it into a block element:
img {
display: block;
margin: auto;
width: 50%;
}
Image Filters
The CSS filter property adds visual effects (like blur and saturation) to an element.
Note: The filter property is not supported in Internet Explorer(IE不支持), Edge 12, or Safari 5.1 and earlier.
CSS Buttons
CSS Pagination Examples
CSS3 Multi-column Layout
The CSS3 multi-column layout allows easy definition of multiple columns of text - just like in newspapers(像报纸文字那样的多栏布局):
In this chapter you will learn about the following multi-column properties:
column-countcolumn-gapcolumn-rule-stylecolumn-rule-widthcolumn-rule-colorcolumn-rulecolumn-spancolumn-width
column-count
The column-count property specifies the number of columns an element(元素被分为多少列) should be divided into.
column-gap
分栏之间的间距
Column Rules
column-rule column-rule-width column-rule-style column-rule-color
分栏之间的宽度 样式 颜色
column-span
元素“横跨”多少栏
column-width
栏目宽度
User Interface
resize
whether or not an element should be resizable by the user.
outline-offset
adds space between an outline and the edge or border of an element.(外边框和边距之间的距离)
Box-sizing
content-box(default),border-box,padding-box
区别在于计算宽度高度时的差别
Flexbox
new layout mode in CSS3
Media Queries
CSS3入门的更多相关文章
- Web大前端时代之:HTML5+CSS3入门系列
准备来一波新技术,待续.... Old: 联系源码:https://github.com/dunitian/LoTHTML5 文档下载:https://github.com/dunitian/LoTD ...
- 07. Web大前端时代之:HTML5+CSS3入门系列~H5 地理位置
Web大前端时代之:HTML5+CSS3入门系列:http://www.cnblogs.com/dunitian/p/5121725.html 源码:https://github.com/duniti ...
- 01.Web大前端时代之:HTML5+CSS3入门系列~初识HTML5
Web大前端时代之:HTML5+CSS3入门系列:http://www.cnblogs.com/dunitian/p/5121725.html 文档申明 <!--文档类型申明,html代表是ht ...
- 02.Web大前端时代之:HTML5+CSS3入门系列~H5结构元素
Web大前端时代之:HTML5+CSS3入门系列:http://www.cnblogs.com/dunitian/p/5121725.html 1.结构元素 可以理解为语义话标记,比如:以前这么写&l ...
- 03.Web大前端时代之:HTML5+CSS3入门系列~H5功能元素
Web大前端时代之:HTML5+CSS3入门系列:http://www.cnblogs.com/dunitian/p/5121725.html 2.功能元素 1.hgroup 对网页或区段(secti ...
- 04. Web大前端时代之:HTML5+CSS3入门系列~HTML5 表单
Web大前端时代之:HTML5+CSS3入门系列:http://www.cnblogs.com/dunitian/p/5121725.html 一.input新增类型: 1.tel:输入类型用于应该包 ...
- 05. Web大前端时代之:HTML5+CSS3入门系列~H5 多媒体系
Web大前端时代之:HTML5+CSS3入门系列:http://www.cnblogs.com/dunitian/p/5121725.html 1.引入 概述 音频文件或视频文件都可以看做是一个容器文 ...
- 06. Web大前端时代之:HTML5+CSS3入门系列~HTML5 画布
Web大前端时代之:HTML5+CSS3入门系列:http://www.cnblogs.com/dunitian/p/5121725.html 我们先看看画布的魅力: 初始画布 canvas默认是宽3 ...
- 08. Web大前端时代之:HTML5+CSS3入门系列~H5 Web存储
Web大前端时代之:HTML5+CSS3入门系列:http://www.cnblogs.com/dunitian/p/5121725.html
- 08. Web大前端时代之:HTML5+CSS3入门系列 ~ QQ空间时间轴
Web大前端时代之:HTML5+CSS3入门系列:http://www.cnblogs.com/dunitian/p/5121725.html 大前端系列,主要就是使用CSS3.0来实现,注释我已经打 ...
随机推荐
- 从零开始学C++之重载 operator new 和 operator delete 实现一个简单内存泄漏跟踪器
先来说下实现思路:可以实现一个Trace类,调用 operator new 的时候就将指向分配内存的指针.当前文件.当前行等信息添加进Trace 成员map容器内,在调用operator delete ...
- protubuffer for windows配置指南!
windows下Google Protocol Buffer 编译安装教程 protobuf的全称是Protocol Buffer,它是google 的一种数据交换的格式,可用于用于分布式应用 ...
- CALayer之mask属性-遮罩
CALayer有一个属性叫做mask. 这个属性本身就是个CALayer类型,有和其他图层一样的绘制和布局属性. 它类似于一个子图层,相对于父图层(即拥有该属性的图层)布局,但是它却不是一个普通的子图 ...
- Java 编译打包命令
背景 编译 打包 解压 运行 参考 背景 我们有的时候总是要使用将自己写的工程编译成 class 文件,同时打包成 jar,虽然有各种工具可以帮助我们,但是毕竟掌握使用 java 本来的命令去做这些更 ...
- case a.ass_term_unit when '01' then (case a.ass_profit_mode when '0' then round(sum(a.ass_amount*a.ass_annual_rate/365*365*a.ass_term/100) ,2) when '1' then round(sum(a.ass_amount*a.ass_annual_rate/
--01 年 02 月 03 日 select a.ass_due_date, case a.ass_term_unit when '01' then (case a.ass_profit_mode ...
- Egret --视觉编程,显示对象,事件
1,在egret中,视觉图形都是由显示对象和显示对象容器组成的: 显示对象:准确的说,就是在舞台上显示出来的,包括能真实看见的图形,文字,图片,视频等:也包括不能看见但真实存在的显示对象容器: 一:显 ...
- 实时控制软件第一周 汽车ABS系统软件分析
abs系统简介 在踩急刹车的时候,若没有额外的控制,容易使车轮完全停止转动,从而出现车轮打滑,车轮导向作用丧失的危险情况. abs系统的作用是在驾驶员完全踩住制动踏板的情况下,通过实时地测量车轮转速, ...
- deployd使用归纳
deployd:一个生成后端数据的软件,简单的说就是大部分的前端不会后端,即使会也很难在深入到数据库进行设置一些前端所需数据的创建与查询的后端程序的书写,所以此时就是deployd大显身手的时候了. ...
- 使用ab对站点进行压力测试
测试指令: window下: E:\wamp\bin\apache\Apache2.2.21\bin> .\ab -V //查看是否按照了ab:(V 大写) E:\wamp\bin\apach ...
- Unity3DGUI:常用控件