File: css-style.md

package info (click to toggle)
node-stylus 0.48.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,196 kB
  • ctags: 766
  • sloc: makefile: 38
file content (103 lines) | stat: -rw-r--r-- 2,687 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
layout: default
permalink: docs/css-style.html
---

# CSS Style Syntax

 Stylus transparently supports a regular CSS-style syntax. This means you don't need an alternative parser, or specify that a certain file uses a specific style.

## Example

 Below is a small style using the indented approach:
 
     border-radius()
       -webkit-border-radius arguments
       -moz-border-radius arguments
       border-radius arguments

     body a
       font 12px/1.4 "Lucida Grande", Arial, sans-serif
       background black
       color #ccc

     form input
       padding 5px
       border 1px solid
       border-radius 5px

 Since braces, colons, and semi-colons are optional, we could write this example just as we would with normal CSS:
 
     border-radius() {
       -webkit-border-radius: arguments;
       -moz-border-radius: arguments;
       border-radius: arguments;
     }

     body a {
       font: 12px/1.4 "Lucida Grande", Arial, sans-serif;
       background: black;
       color: #ccc;
     }

     form input {
       padding: 5px;
       border: 1px solid;
       border-radius: 5px;
     }

While Stylus don't support _every_ possible CSS-like syntax, if can understand even such code:

        border-radius() {
          -webkit-border-radius: arguments;
          -moz-border-radius: arguments;
          border-radius: arguments;
        }

    body a
    {
      font: 12px/1.4 "Lucida Grande", Arial, sans-serif;
        background: black;
      color: #ccc;
    }

        form input {
          padding: 5px;
      border: 1px solid;
          border-radius: 5px;
          }


 Since we may mix and match the two variants, the following is valid as well:
 
     border-radius()
       -webkit-border-radius: arguments;
       -moz-border-radius: arguments;
       border-radius: arguments;

     body a {
       font: 12px/1.4 "Lucida Grande", Arial, sans-serif;
       background: black;
       color: #ccc;
     }

     form input
       padding: 5px;
       border: 1px solid;
       border-radius: 5px;

 Variables, functions, mixins, and all the other features provided by Stylus still work as expected:
 
     main-color = white
     main-hover-color = black

     body a {
       color: main-color;
       &:hover { color: main-hover-color; }
     }

     body a { color: main-color; &:hover { color: main-hover-color; }}

 There are a few caveats to this rule: since the two styles may be mixed and matched, some indentation rules still apply. So although not _every_ plain-CSS stylesheet will work with zero modification, this feature allows those who prefer CSS syntax to continue doing so while leveraging Stylus' other powerful features.