css - reactjs 内联样式 gridColumn 不尊重跨度

标签 css reactjs

我正在尝试使用 span 允许使用 grid-column 的事件在日历中分布在多天,但这似乎只适用于 css 或样式组件。它在内联样式中不起作用。任何人有任何想法使它与内联样式一起工作吗?

代码沙盒:https://codesandbox.io/s/react-event-calendar-8v9o1?file=/src/Components/CalendarEvent.js

代码片段:

    <span
      className="calendar-event-label"
      styled={{gridColumnStart: col, gridColumnEnd: `span ${colSpan}`}}
      onClick={onClick}
    >{title}</span>

最佳答案

使用 Style 而不是 Styled

style={{
        gridColumnStart: col,
        gridColumnEnd: `span ${colSpan}`
      }}

我检查了它工作的代码沙箱中的更改。

工作:https://codesandbox.io/s/react-event-calendar-forked-4s0h9

关于css - reactjs 内联样式 gridColumn 不尊重跨度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66433990/

相关文章:

html - 为什么我的 div 不显示内联?

jquery - AngularJS 和 jQuery : Splitting textarea into multiple textareas

javascript - 如果没有在 JS 或 CSS 中的任何地方指定该属性,我如何找到 JS 样式属性的值?

HTML Wamp - 需要调试

html - IE11 中 flexbox 中的图像大小不正确

reactjs - 无法在 React 中使用 FontAwesome 在 'removeChild' 上执行 'Node'

javascript - 如何从react js中的事件处理程序渲染父元素中的子元素

reactjs - 如何避免使用 Typescript 在 React 构造函数中重新声明 Prop 类型

reactjs - react 应用程序 : Why I get an error when I try to run npm start script?

javascript - 我如何解构 {this.props.children}?