我正在使用react-toolbox和react-toolbox-themr依賴關係將材料設計集成到reactjs中。在使用卡片組件時,我想自定義作爲標籤屬性的標題和副標題的CSS。我怎樣才能添加CSS到字幕和標題的卡?重寫css中的材料設計類
我的組件看起來像這樣。
import React, { Component } from 'react';
import {Display} from './Display.js';
import './toolbox/theme.css';
import theme from './toolbox/theme'
import ThemeProvider from 'react-toolbox/lib/ThemeProvider'
import Button from 'react-toolbox/lib/button/Button.js';
import IconButton from 'react-toolbox/lib/button/IconButton.js';
import Avatar from 'react-toolbox/lib/avatar/Avatar.js';
import Card from 'react-toolbox/lib/card/Card.js';
import CardTitle from 'react-toolbox/lib/card/CardTitle.js';
import CardText from 'react-toolbox/lib/card/CardText.js';
import {Constants} from './constants.js';
import axios from 'axios';
import moment from 'moment';
const test = require('./App.css')
export class QueryList extends React.Component{
constructor(props) {
super(props);
this.dummyText = "ABCDEFGHIJKLMNOP"
this.state = {
querylist: []
};
}
componentDidMount(){
this.loadData();
}
loadData(){
var me=this;
axios({
method:Constants.methods[0],
url:Constants.URLConst+"/Query?pageNum=1&totalperPage=15&userid=0",
headers: Constants.headers
}).then(function(response){
me.setState({
querylist: response.data.QueryListDetails.QueryData
})
}).catch(function(error){
console.log(error);
})
}
render(){
var i=1;
var listQueries = this.state.querylist.map(function(item) {
item.QueryPostedDate = "Posted On "+moment(item.QueryPostedDate).format('DD/MM/YYYY HH:mm:Ss A');
return (
<Card className="query-card" key={i++}>
<CardTitle
className={test.themedCardTitle}
title={item.QueryText}
subtitle={item.QueryPostedDate}
theme={test}
/>
</Card>
);
});
return(
<ThemeProvider theme={theme}>
<div>
<Display/>
{listQueries}
</div>
</ThemeProvider>
)
}
}
在App.css我有這樣的事情。
.themedCardTitle.cardTitle {
.subtitle {
color: pink;
}
}
但是副標題不會變成粉紅色。我在這裏做錯了什麼?
'.themedCardTitle.cardTitle'是什麼語法?你想用它實現什麼,將它應用於這兩個類? – Jayce444
我從這裏引用它https://github.com/react-toolbox/react-toolbox/issues/688 – Aayushi
分享你嘗試風格的元素和當前適用的CSS規則。 – jmargolisvt