- 首先全局安装
- yarn add styled-components
- 使用
- 引入的样式文件不再事css文件,都改成js文件,但是引入方法还是css的引入方法。
- 在样式文件中引入:
- import { createGlobalStyle } from 'styled-components';
- 全局样式添加样式都导出:
- 搜索全局样式文件reset.css,然后复制里面的内容添加到下面
-
export const Globalstyle = createGlobalStyle`
body {
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}}`
react css模块管理工具 styled-components
最新推荐文章于 2024-09-26 08:23:13 发布
