使用 react 作法
npm i @emotion/react
import { css, jsx } from '@emotion/react'
const color = 'white'
render(
<div
css={css`
padding: 32px;
background-color: hotpink;
font-size: 24px;
border-radius: 4px;
&:hover {
color: ${color};
}
`}
>
Demo
</div>
)
使用这种方式的 css, 最终 css``` 不会产生一个新的 className, 会直接对 element 做 style 的附加,如果
css ``` 经由父传子,且有相同的 css 属性,则後者会盖掉前者。
import { jsx } from '@emotion/react'
const Child = props => (
<p
css={css`
margin: 0,
fontSize: 12,
lineHeight: 1.5,
fontFamily: 'Sans-Serif',
color: black`
}
/>
)
const Parent = props => (
<Child
css={
css`
fontSize: 14,
fontFamily: 'Georgia, serif',
color: darkgray
`
}
/>
)
import { jsx } from '@emotion/react'
const Child = props => (
<p
css={css`
margin: 0;
fontSize: 12;
lineHeight: 1.5;
fontFamily: 'Sans-Serif';
color: black;`
}
/>
)
const Parent = props => (
<Child
css={
css`
fontSize: 14;
fontFamily: 'Georgia, serif';
color: darkgray;
`
}
/>
)
// 最後 Child 剩下的 style
{
*fontSize: 14;* //被删除
*fontFamily: 'Georgia, serif';* //被删除
*color: darkgray;* //被删除
margin: 0;
fontSize: 12;
lineHeight: 1.5;
fontFamily: 'Sans-Serif';
color: black;
}
<<: [想试试看JavaScript ] 阵列一些操作阵列好用的方法
>>: 新新新手阅读 Angular 文件 - Component - Day23
push 刻好画面後,在 ViewController.swift ( MainVC.swift )...
9.4 关於三连通的练习题 这题超难,我把连结放这边就好。 https://acm.timus.ru...
昨天有改了Products表格,先换一下 -- Table: public.products -- ...
前言 飙车回家又是11点多了,发现今天的daily challenge是easy就顺手解个吧!题目在...
为什麽需要 Media Queries Media queries 可以让我们依据不同装置的特性来调...