-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


CSS.

, 04 2017 . 08:46 +


, CSS , , , . , . . , , CSS ( ) . , .

, , .. . , - (, , , , ...). , CSS, , .

, .
:

:root {
    --body-background: #ccc;
}

body {
  background-color: var(--body-background);
}


, :
--variable-name

, var.
2 . , , , , .

, , . CSS, . , <320px , . . ..

.title {
  --wrapper-width: 50%;
  width: var(--wrapper-width);
}

@media (max-width: 320px) {
  --wrapper-width: 100%;
}

! , width !

CSS , , .

JavaScript?


style, , . React.

.title {
  --background: blue;
  background-color: var(--background);
}

changeColor() {
  this.setState({
    style: {'--background': 'green'}
  });
}
Title

title . ? ! , , .
- React - , . JavaScript style ,
--background


, css , , .


CSS , . . .. --b html . --a body ( - ).
html {
  --a: #ccc;
}
body {
  --b: #a3a3a3;
}

( , , hex- :))

calc


, calc.
.title {
  --title-width: 300px;
  width: calc(var(--title-width) + 150px);
}

! --title-width, CSS, .

, . px, %, rem .. . calc .

.title {
  --title-width: 300;
  /*    */
  width: var(--title-width)px;
  /*   */
  width: calc(var(--title-width) * 1px);
}



CSS , , . . caniuse, IE , Edge .

Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/332038/

:  

: [1] []
 

:
: 

: ( )

:

  URL