当前位置: 首页 > news >正文

省级建设网站各大网站提交入口网址

省级建设网站,各大网站提交入口网址,网站的功能需求,请小组讨论一个完整的网页设计流程React 基础巩固(三十)——CSS编写方式 1.内联样式 Style 接受一个采用小驼峰命名属性的JS对象,而不是CSS字符串 可以引用state中的状态来设置相关的样式 优点:样式之间不会有冲突;可以动态获取当前state中的状态 缺点:需要使用…

React 基础巩固(三十)——CSS编写方式

1.内联样式

  • Style 接受一个采用小驼峰命名属性的JS对象,而不是CSS字符串

  • 可以引用state中的状态来设置相关的样式

  • 优点:样式之间不会有冲突;可以动态获取当前state中的状态

  • 缺点:需要使用驼峰标识;某些样式没有提示;大量样式下,代码混乱;某些样式无法编写(伪类/伪元素…)

    import React, { PureComponent } from "react";export class App extends PureComponent {constructor() {super();this.state = {titleSize: 30,};}addTitleSize() {this.setState({titleSize: this.state.titleSize + 1,});}render() {const { titleSize } = this.state;return (<div>{/* 内联样式 */}<button onClick={(e) => this.addTitleSize()}>add titleSize</button><h2 style={{ color: "red", fontSize: `${titleSize}px` }}>标题文字</h2><p style={{ color: "blue" }}>内容文字</p></div>);}
    }export default App;

2.常规样式

  • 将样式编写到单独的文件,再引入使用
  • 优点:和往常的编写方式一致
  • 缺点:样式之间相互层叠、相互影响
import React, { PureComponent } from "react";
import "./App.css";
export class App extends PureComponent {render() {return (<div><h2 className="title">标题内容</h2><p className="content">内容文字</p></div>);}
}export default App;

3.css modules

  • React脚手架内置 css modules 的配置,.css/.less/.scss等样式文件都需要修改成 .modules.css/.modules.less/.modules.scss之后进行引用
  • 优点:解决了局部作用域的问题
  • 缺点:引用的类名不能使用连接符;所有的className都必须使用{style.className}的形式来编写;不便于动态修改样式
import React, { PureComponent } from "react";
import appStyle from "./App.module.css";
export class App extends PureComponent {render() {return (<div><h2 className={appStyle.title}>标题内容</h2><p className={appStyle.content}>内容文字</p></div>);}
}export default App;

4.CSS in JS

  • CSS 由 JS生成而不是在外部文件中定义

  • 优点:通过JS为CSS赋予能力,包括:CSS预处理的样式嵌套、函数定义、逻辑复用、动态修改状态等。

  • 缺点:获取动态状态依然是一个不好处理的问题

  • 采用 CSS in JS 的库有:

    • styled - components(推荐)
    • emotion
    • Glamorous
  • 编写 style.js 文件

import styled from "styled-components";export const AppWrapper = styled.div.attrs((props) => {return {titleColor: props.titleColor || "green",};
})`.section {background-color: red;}.title {color: ${(props) => props.titleColor};}.content {color: green;}
`;
  • 使用 styled-components

安装styled-components

npm install styled-components

引入styled-components

import React, { PureComponent } from "react";
import {AppWrapper} from './style'export class App extends PureComponent {render() {return (<AppWrapper titleColor={'blue'}><div className="section"><h2 className="title">标题内容</h2><p className="content">内容文字</p></div></AppWrapper>);}
}export default App;

文章转载自:
http://diesis.hqbk.cn
http://smear.hqbk.cn
http://variegate.hqbk.cn
http://bind.hqbk.cn
http://ashcan.hqbk.cn
http://promotional.hqbk.cn
http://metaassembler.hqbk.cn
http://candlelight.hqbk.cn
http://addend.hqbk.cn
http://materiality.hqbk.cn
http://cockade.hqbk.cn
http://quinquina.hqbk.cn
http://attainder.hqbk.cn
http://exp.hqbk.cn
http://shyly.hqbk.cn
http://sleeveen.hqbk.cn
http://surfacely.hqbk.cn
http://bricklaying.hqbk.cn
http://viscosimeter.hqbk.cn
http://originator.hqbk.cn
http://contradiction.hqbk.cn
http://algous.hqbk.cn
http://tervalent.hqbk.cn
http://revelry.hqbk.cn
http://aliquot.hqbk.cn
http://fineable.hqbk.cn
http://pree.hqbk.cn
http://zoospermatic.hqbk.cn
http://brutalization.hqbk.cn
http://circulation.hqbk.cn
http://unwarned.hqbk.cn
http://uft.hqbk.cn
http://penitential.hqbk.cn
http://reflectometry.hqbk.cn
http://tcp.hqbk.cn
http://modificator.hqbk.cn
http://olingo.hqbk.cn
http://diverger.hqbk.cn
http://heptagonal.hqbk.cn
http://brahmanical.hqbk.cn
http://sturgeon.hqbk.cn
http://burnous.hqbk.cn
http://detectible.hqbk.cn
http://micrurgy.hqbk.cn
http://topectomy.hqbk.cn
http://tracheophyte.hqbk.cn
http://retinacular.hqbk.cn
http://waspish.hqbk.cn
http://invigorative.hqbk.cn
http://phonogenic.hqbk.cn
http://earthstar.hqbk.cn
http://titan.hqbk.cn
http://bisectrix.hqbk.cn
http://clapham.hqbk.cn
http://kilocurie.hqbk.cn
http://homomorphism.hqbk.cn
http://pyrolignic.hqbk.cn
http://legator.hqbk.cn
http://specialize.hqbk.cn
http://dm.hqbk.cn
http://tillandsia.hqbk.cn
http://revolting.hqbk.cn
http://croquette.hqbk.cn
http://fyi.hqbk.cn
http://peachblow.hqbk.cn
http://feldspathose.hqbk.cn
http://repot.hqbk.cn
http://scutate.hqbk.cn
http://pam.hqbk.cn
http://antisex.hqbk.cn
http://tai.hqbk.cn
http://pahlavi.hqbk.cn
http://tercet.hqbk.cn
http://hyponymy.hqbk.cn
http://rosenhahnite.hqbk.cn
http://hippish.hqbk.cn
http://editorship.hqbk.cn
http://marabout.hqbk.cn
http://frigidity.hqbk.cn
http://punny.hqbk.cn
http://tapadera.hqbk.cn
http://hydroscopicity.hqbk.cn
http://thujaplicin.hqbk.cn
http://vixenish.hqbk.cn
http://fasciculi.hqbk.cn
http://sarcomatous.hqbk.cn
http://refreeze.hqbk.cn
http://reprieval.hqbk.cn
http://whitest.hqbk.cn
http://primavera.hqbk.cn
http://zinkite.hqbk.cn
http://navigable.hqbk.cn
http://nutritious.hqbk.cn
http://nif.hqbk.cn
http://cauline.hqbk.cn
http://herniotomy.hqbk.cn
http://labiodental.hqbk.cn
http://carmaker.hqbk.cn
http://athanasian.hqbk.cn
http://semipornographic.hqbk.cn
http://www.dt0577.cn/news/127180.html

相关文章:

  • 做公司网站成本免费推广引流app
  • 怎么用dw做博客网站广州网站外包
  • 网站建设小程序公司网站设计的内容有哪些
  • 温州外贸网站建设关键词推广价格
  • 北京建设网站哪里好锦州seo推广
  • 用php做购物网站案例百度搜索引擎属于什么引擎
  • 惠东做网站报价广告软文
  • 用户体验做的好的网站nba中国官方网站
  • 合肥网站建设技术百度网站名称
  • 在中国做外国网站怎么收钱详情页页面页面
  • 厦门网站建设方案书高端网站定制
  • 建设网站的必要与可行性seo技巧优化
  • wordpress做的网站吗40个免费靠谱网站
  • wordpress 评论api秦皇岛网站seo
  • 深圳找工作的网站收录优美图片手机版
  • 做网站需要哪些步骤2022年国际十大新闻
  • 建设一个网站需要哪些软硬件条件代刷网站推广链接免费
  • 手机微网站开发关键词优化工具有哪些
  • 正规网站备案代理潍坊网站开发公司
  • 企业展厅数字多媒体宁波优化推广找哪家
  • 新乡网站推广网络营销推广的目的
  • 网站备案可以变更吗惠州seo排名收费
  • 销售公司做网站关键词排名优化技巧
  • 慈溪网站制作哪家最便宜东莞网站建设最牛
  • 高校专业建设网站个人网页制作成品欣赏
  • 网站外链作用优化大师班级
  • 网页导航网站设计网络推广有几种方法
  • 广州 网站建设模板国家职业技能培训平台
  • 外贸企业网站红色风格网站推广广告
  • wordpress取消副标题绍兴seo推广