Less, bootstrap and more

19

Click here to load reader

description

A simple introduction.

Transcript of Less, bootstrap and more

Page 1: Less, bootstrap and more

1

Less, Bootstrap and more

A simple introduction.

Page 2: Less, bootstrap and more

2

What is LESS?

{Less} extends CSS with variables, nested rules, operators and more. If you're still building websites without it, you're an idiot.

Page 3: Less, bootstrap and more

3

Why LESS?

• So you can define 变量 (like colors, distances etc.), which then can be used in the rest of the file – great to have all used colors in one place only.

• Furthermore there are user-defined 函数 , like .rounded here, a shortcut to add the three possible border-radius methods.

• You can even add 参数 (in this case radius) with a default value.

• And 嵌套 classes (.navi a) can be written more naturally.

Page 4: Less, bootstrap and more

4

How LESS?

2 ways:• 编译版本put your Less-files and automatically creates the corresponding CSS-file, with error checking and minification if desired.• JS驱动版本<link rel="stylesheet/less" type="text/css" href="site.less"><script type="text/javascript" src="less-1.0.41.min.js"></script>

Page 5: Less, bootstrap and more

5

Sample@linkcolor: #9999C9;@spacing_left: 60px;

.rounded(@radius: 3px) { -webkit-border-radius: @radius; -moz-border-radius: @radius; border-radius: @radius;}

.navi { .rounded(5px); a { color: @linkcolor; }}

div.navigation { padding-left: @spacing_left;}

Page 6: Less, bootstrap and more

6

More

.darker { color: darken(@mycolor, 10%); background-color: lighten(@mybg, 15%); padding-right: @spacing_left * 2; padding-bottom: (@spacing_left + 5) * 2;}

Page 7: Less, bootstrap and more

7

Fxxk GFW

Page 8: Less, bootstrap and more

8

What is Bootstrap?

Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites.It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.

Page 9: Less, bootstrap and more

9

Why Bootstrap?

• Easy• Fast• Consistent

Page 10: Less, bootstrap and more

10

How Bootstrap?

2 ways• 直接引用样式<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap-1.2.0.min.css">• +Less<link rel="stylesheet/less" href="/path/to/bootstrap.less"><script src="/path/to/less.js"></script>

Page 11: Less, bootstrap and more

11

+

Page 12: Less, bootstrap and more

12

+

Page 13: Less, bootstrap and more

13

+

Page 14: Less, bootstrap and more

14

+

Page 15: Less, bootstrap and more

15

转变思维以 1kb grid为例,传统 CSS:

Page 16: Less, bootstrap and more

16

转变思维转变为 LESS思维——变量:

Page 17: Less, bootstrap and more

17

转变思维转变为 LESS思维——变量 +函数:

Page 18: Less, bootstrap and more

18

实战?适合跟 v6整体关联不大、页面较多、更新块的业务。

Page 19: Less, bootstrap and more

19

Thx~