Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set -webkit-overflow-scrolling inline style on react component

I am using inline style for react component. They can be defined as below.

const style= {
    position: 'absolute',
    left: 0,
    right: 0,
    bottom: '7.5%',
    top: '5.2rem',
    overflowY: 'auto',
  },

It has some gramma different with css, like 'overflow-y' in css should be set as overflowY in inline style. Now I wander how to set this style -webkit-overflow-scrolling as inline style in react? I have tried below settings but none of them work.

WebkitOverflowScrolling: 'touch',
'-webkit-overflow-scrolling': 'touch',
like image 248
Joey Yi Zhao Avatar asked Aug 20 '16 10:08

Joey Yi Zhao


People also ask

How do you add an inline style to a component?

Setting Inline Styles in a React ComponentSpecify the style object inside the constructor as follows. Notice here that the text-align CSS property got camel-cased to textAlign . Pass this styles object to the <H1 /> component, as shown below. Combine multiple style objects using the spread operator.

Can We Use inline CSS in React?

In React, inline styles are not specified as a string. The style attribute accepts a JavaScript object with camelCased properties. Below are the basic steps for defining inline CSS: 1. Change the CSS property name to its camelCase version like "background-color" to "backgroundColor", "font-size" to "fontSize", etc.

How do I change a CSS React?

To change the style of an element on click in React:Set the onClick prop on the element. When the element is clicked, set the active state. Use a ternary operator to conditionally set the new styles based on the state variable.


1 Answers

I've used this successfully:

overflowScrolling: "touch",
WebkitOverflowScrolling: "touch",
like image 179
Epeli Avatar answered Sep 29 '22 11:09

Epeli