第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

css in js用法?

在定義React組件的樣式時(shí),用css in js的寫法可以定義當(dāng)前組件的樣式,但是當(dāng)各個(gè)組件之間有布局關(guān)系時(shí),怎么用css in js來(lái)控制?

正在回答

2 回答

用styled component可以嵌套

import?React,?{?Component?}?from?'react'
import?styled?from?'styled-components'

//?頂部導(dǎo)航子組件
const?list?=?[
????{id:0,name:'免費(fèi)課程',url:'http://idcbgp.cn/course/list'},
????{id:1,name:'職業(yè)路徑',url:'https://class.imooc.com/'},
????{id:2,name:'實(shí)戰(zhàn)',url:'https://coding.imooc.com/'},
????{id:3,name:'猿問(wèn)',url:'http://idcbgp.cn/wenda'},
????{id:4,name:'手記',url:'http://idcbgp.cn/article'}
]

const?Nav?=?({className})?=>?(
????<ul?className={className}>
????????{
????????????list.map(n=>
????????????????<li?key={n.id}>
????????????????????<a?href={n.url}>{n.name}</a>
????????????????</li>
????????????)
????????}
????</ul>
)

const?StyleNav?=?styled(Nav)`
????display:flex;
????a?{
???????padding:?0?20px;
???????color:?#4D555D;
???????font-size:?16px;
???????line-height:?72px;
???????text-align:center;
???????transition:?background-color?.3s;
????}
????li:nth-of-type(2)?a:after?{
????????content:?'';
????????position:?relative;
????????display:?inline-block;
????????top:?-10px;
????????width:?16px;
????????height:?16px;
????????background:?url(http://idcbgp.cn/static/img/common/new.png)?no-repeat;
????}
`

class?Head?extends?Component?{
????render()?{
????????return?(
????????????<Header?id='Head'>
????????????????<StyleNav?className='topBarNav'/>
????????????</Header>
????????)
????}
}

export?default?Head
0 回復(fù) 有任何疑惑可以回復(fù)我~

可以嘗試用className寫樣式

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
React實(shí)戰(zhàn)--打造畫廊應(yīng)用(上)
  • 參與學(xué)習(xí)       57293    人
  • 解答問(wèn)題       283    個(gè)

顛覆式前端UI開發(fā)框架 React,打造圖片畫廊實(shí)踐案講解

進(jìn)入課程
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)