我正在尝试在屏幕的右下方添加FloatingActionButton
。我正在使用此库http://www.material-ui.com/#/components/floating-action-button
import React, { Component } from "react";
import logo from "./logo.svg";
import "./App.css";
import AppBar from "material-ui/AppBar";
import FloatingActionButton from "material-ui/FloatingActionButton";
import MuiThemeProvider from "material-ui/styles/MuiThemeProvider";
import * as strings from "./Strings";
import styles from "./Styles";
import ContentAdd from "material-ui/svg-icons/content/add";
const AppBarTest = () =>
<AppBar
title={strings.app_name}
iconClassNameRight="muidocs-icon-navigation-expand-more"
/>;
class App extends Component {
render() {
return (
<MuiThemeProvider>
<div>
<AppBarTest />
<FloatingActionButton style={styles.fab}>
<ContentAdd />
</FloatingActionButton>
</div>
</MuiThemeProvider>
);
}
}
export default App;
Styles.js
const style = {
fab: {
backgroundColor: '#000000'
},
};
export default style;
它在左上角显示FloatingActionButton
,我想在右下方显示FloatingActionButton
。这样做的方法是什么?
为什么样式不适用于{{1}}?
答案 0 :(得分:5)
试试这种风格:
const fabStyle = {
right: 20,
position: 'fixed'
};
以后你使用margin,top ...但不要在position: fixed
上使用auto