|
1 | 1 | --- |
2 | 2 | id: faq-styling |
3 | | -title: Styling and CSS |
| 3 | +title: Стилизация и CSS |
4 | 4 | permalink: docs/faq-styling.html |
5 | 5 | layout: docs |
6 | 6 | category: FAQ |
7 | 7 | --- |
8 | 8 |
|
9 | | -### How do I add CSS classes to components? {#how-do-i-add-css-classes-to-components} |
| 9 | +### Как добавить CSS-классы в компоненты? {#how-do-i-add-css-classes-to-components} |
10 | 10 |
|
11 | | -Pass a string as the `className` prop: |
| 11 | +Передайте в проп `className` строку: |
12 | 12 |
|
13 | 13 | ```jsx |
14 | 14 | render() { |
15 | | - return <span className="menu navigation-menu">Menu</span> |
| 15 | + return <span className="menu navigation-menu">Меню</span> |
16 | 16 | } |
17 | 17 | ``` |
18 | 18 |
|
19 | | -It is common for CSS classes to depend on the component props or state: |
| 19 | +Обычно CSS-классы зависят от пропсов или состояния: |
20 | 20 |
|
21 | 21 | ```jsx |
22 | 22 | render() { |
23 | 23 | let className = 'menu'; |
24 | 24 | if (this.props.isActive) { |
25 | 25 | className += ' menu-active'; |
26 | 26 | } |
27 | | - return <span className={className}>Menu</span> |
| 27 | + return <span className={className}>Меню</span> |
28 | 28 | } |
29 | 29 | ``` |
30 | 30 |
|
31 | | ->Tip |
| 31 | +>Совет |
32 | 32 | > |
33 | | ->If you often find yourself writing code like this, [classnames](https://www.npmjs.com/package/classnames#usage-with-reactjs) package can simplify it. |
| 33 | +>Если вы часто пишите похожий код, то пакет [classnames](https://www.npmjs.com/package/classnames#usage-with-reactjs) поможет упростить его. |
34 | 34 |
|
35 | | -### Can I use inline styles? {#can-i-use-inline-styles} |
| 35 | +### Как можно использовать встроенные стили? {#can-i-use-inline-styles} |
36 | 36 |
|
37 | | -Yes, see the docs on styling [here](/docs/dom-elements.html#style). |
| 37 | +Конечно, прочитайте [документацию об элементах DOM](/docs/dom-elements.html#style). |
38 | 38 |
|
39 | | -### Are inline styles bad? {#are-inline-styles-bad} |
| 39 | +### Встроенные стили — это плохо? {#are-inline-styles-bad} |
40 | 40 |
|
41 | | -CSS classes are generally better for performance than inline styles. |
| 41 | +CSS-классы, как правило, лучше для производительности, чем встроенные стили. |
42 | 42 |
|
43 | | -### What is CSS-in-JS? {#what-is-css-in-js} |
| 43 | +### Что такое CSS-in-JS? {#what-is-css-in-js} |
44 | 44 |
|
45 | | -"CSS-in-JS" refers to a pattern where CSS is composed using JavaScript instead of defined in external files. Read a comparison of CSS-in-JS libraries [here](https://github.com/MicheleBertoli/css-in-js). |
| 45 | +«CSS-in-JS» — это паттерн, в котором CSS-код создаётся при помощи JavaScript, вместо того, чтобы писать его во внешних файлах. Ознакомтесь со сравнением библиотек по работе с «CSS-in-JS» в [этом репозитории](https://github.com/MicheleBertoli/css-in-js). |
46 | 46 |
|
47 | | -_Note that this functionality is not a part of React, but provided by third-party libraries._ React does not have an opinion about how styles are defined; if in doubt, a good starting point is to define your styles in a separate `*.css` file as usual and refer to them using [`className`](/docs/dom-elements.html#classname). |
| 47 | +_Обратите внимание, что данная функциональность не входит в React из коробки, а предоставляется сторонними библиотеками._ React ничего не знает про то, как определяются стили. Если вы сомневаетесь, использовать указанный выше способ, то хорошим началом станет определение стилей в отдельном файле с расширением `*.css`, как вы ранее привыкли это делать, а затем указать нужные классы с помощью [`className`](/docs/dom-elements.html#classname). |
48 | 48 |
|
49 | | -### Can I do animations in React? {#can-i-do-animations-in-react} |
| 49 | +### Можно создавать анимации в React? {#can-i-do-animations-in-react} |
50 | 50 |
|
51 | | -React can be used to power animations. See [React Transition Group](https://reactcommunity.org/react-transition-group/) and [React Motion](https://github.com/chenglou/react-motion), for example. |
| 51 | +React может использоваться для создания крутых анимаций! В качестве примера посмотрите библиотеки [React Transition Group](https://reactcommunity.org/react-transition-group/) и [React Motion](https://github.com/chenglou/react-motion). |
0 commit comments