如何始终在整页中显示React应用程序?

丹尼斯·伊万年科(Denis Ivanenko)

我正在使用React和Material UI开发应用程序,并尝试以全页模式显示该应用程序,但是无法做到。当前,它看起来像这样:当前外观

我的App.js代码:

import 'typeface-roboto';
import './css/App.css'
import React from 'react';
import ArticlePage from "./pages/article";
import ProfilePage from "./pages/profile";
import {MuiThemeProvider} from "material-ui";
import CssBaseline from "@material-ui/core/CssBaseline";
import {BrowserRouter as Router, Switch, Route} from "react-router-dom";
import NavBar from "./components/NavBar";
import HomePage from "./pages/home";
import InboxPage from "./pages/inbox";

function App() {
    return (
        <MuiThemeProvider>
            <div className="App">
                <Router>
                    <CssBaseline/>
                    <NavBar/>
                    <Switch>
                        <Route path="/profile">
                            <ProfilePage profileName={"Denis Ivanenko"} dateTime={"2017-02-14"}
                                         userBio={"Example of User Bio. Here User can write about himself."}/>
                        </Route>
                        <Route path="/article">
                            <ArticlePage
                                imageSrc={"https://insights.dice.com/wp-content/uploads/2017/09/shutterstock_315465929.jpg"}
                                text={"Ever spent three hours trying to find that bit of knowledge that everyone seemed to have but you?\n" +
                                "\n" +
                                "As a self-trained Python developer, I've sometimes found myself stuck in that knowledge crater, between tutorials far simpler than real life, and articles more advanced than I could comprehend. Even the documentation felt like a firehose of information, making it nearly impossible to find the one basic thing I needed to know.\n" +
                                "\n" +
                                "In this series, I'll be exploring a few of these topics, in a way that hopefully makes them dead simple!\n" +
                                "\n" +
                                "Intended Audience\n" +
                                "While programmers at all experience levels may find this series useful, I'm specifically targeting Python novices. I am assuming, however, that you have a very basic understanding of programming. The coding topics especially will be more focused on the Python way of doing things, not on the underlying generic concept.\n" +
                                "\n" +
                                "With that said, if you're an intermediate-level Python developer, you may still find it helpful to follow along with the series. Although I've been working with Python for nearly eight years, some of these topics didn't really \"click\" for me until recent years. These are the explanations I wish I'd had!\n" +
                                "\n" +
                                "What You Won't Find Here\n" +
                                "All of the topics I'm discussing here go much, much deeper. However, I don't want to muddy the waters, so I'll be omitting a considerable amount of detail. Once you're comfortable with a topic, and have done it a few times yourself, I recommend going back and reading through the official Python documentation on the topic.\n" +
                                "\n" +
                                "A Note on Python Versions\n" +
                                "The official end-of-life for Python 2 is rapidly approaching, so you should learn and begin using Python 3 as soon as possible! This entire series is geared towards Python 3, with a bias towards 3.6 and 3.7, except as otherwise noted.\n" +
                                "\n" +
                                "Edits\n" +
                                "The articles in this series are frequently being reviewed by my fellow Python experts, and by the Dev community at large. I will expand and revise accordingly. Always check the edit timestamp at the top of the article.\n" +
                                "\n" +
                                "Roadmap\n" +
                                "The current series plan is below. Please note, I may rearrange, add, or remove planned sections."}
                                authorImageSrc={"https://lh5.googleusercontent.com/--OlyHl449xI/AAAAAAAAAAI/AAAAAAAAAAA/ACevoQNk7ZZElQ_vKIQT_6d4HZw_wN3Qxg/mo/photo.jpg?sz=64"}
                                authorName={"Denis Ivanenko"}
                                dateTime={"2017-02-14"}
                                title={"Introducing \"Dead Simple Python\"\n"}
                                subtitle={"Introduction"}
                            />
                        </Route>
                        <Route path="/inbox">
                            <InboxPage name={"Denis"} surname={"Ivanenko"}
                                       messages={[{
                                           author: "Bill Gates",
                                           text: "Hi, how are you?"
                                       }, {author: "Bill Gates", text: "Hi, how are you?"}, {
                                           author: "Bill Gates",
                                           text: "Hi, how are you?"
                                       }, {author: "Bill Gates", text: "Hi, how are you?"}]}/>
                        </Route>
                        <Route path="/">
                            <HomePage/>
                        </Route>
                    </Switch>
                </Router>
            </div>


        </MuiThemeProvider>
    );
}

export default App;

App.css

.App {
    background: #485563;
    background: -webkit-linear-gradient(to right, #29323c, #485563);
    background: linear-gradient(to right, #29323c, #485563);
    height: 100%;
    margin: 0;
    padding: 0;
}

PS我是前端开发的新手,如果这个问题很愚蠢,请您谅解。可能是我在设置背景色时错过了一些东西。谁能帮我?当我在应用程序中使用React Router时,我添加了特定页面的代码,也许问题出在这里。
Inbox.js

import React from "react";
import Paper from "@material-ui/core/Paper";
import Container from "@material-ui/core/Container";
import '../css/Inbox.css';
import {Divider} from "@material-ui/core";
import AvatarImage from "../components/AvatarImage";


export default class InboxPage extends React.Component {
    render() {
        const name = this.props.name;
        const surname = this.props.surname;
        const messages = this.props.messages;
        return (
            <Container>
                <Paper>
                    <h1 className={"inboxHeader"}>{name}{" " + surname + "`s"} Inbox:</h1>
                    <Divider/>
                    {messages.map((message) =>
                        <Container>
                            <AvatarImage className={"AvatarImage"}/>
                            <h2>{message.author}:</h2>
                            <p>{message.text}</p>
                            <Divider/>
                        </Container>
                    )}
                </Paper>
            </Container>
        );
    }
}

Inbox.css

.inboxHeader {
    text-align: center;
}

h2, p, img {
    display: inline-block;
}
.AvatarImage{
    display: inline-block;
}
.flexbox {
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
}
斯拉夫式

你有没有尝试过

.App {
  margin: 0;
  padding: 0;
  min-height: 100% //or 100vh
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

jQuery移动应用程序标头在某些手机中以整页显示

来自分类Dev

如何始终在flutter应用程序中始终静态显示从Firebase存储下载的图像,单击即可打开并查看

来自分类Dev

如何在Android应用中显示整页广告

来自分类Dev

如何在react-native中更改应用程序的显示名称

来自分类Dev

如何让Emotion / Rollup / Typescript组件CSS显示在使用的React应用程序中?

来自分类Dev

如何在React + socket io应用程序中显示聊天

来自分类Dev

如何在 React Native 应用程序中显示 git-describe?

来自分类Dev

如何使用 React 在浏览器中显示控制台应用程序?

来自分类Dev

如何在 React 应用程序中显示彩色 STL 文件

来自分类Dev

无论如何,React 应用程序都没有显示在 Codepen 中?

来自分类Dev

如何始终在特定的显示器上启动应用程序?

来自分类Dev

osx:如何使cmd-tab(应用程序切换器)菜单始终显示?

来自分类Dev

“ cf应用程序”始终显示0.0%的cpu-如何测量该值?

来自分类Dev

应用程序始终显示在Ubuntu 16.04中的第三位

来自分类Dev

任何应用程序的菜单栏都应始终显示

来自分类Dev

即使退出应用程序,如何在菜单栏中显示应用程序图标

来自分类Dev

如何避免我的android应用程序显示在“最近的应用程序”列表中?

来自分类Dev

如何在Win RT应用程序中的应用程序级别显示进度条?

来自分类Dev

如何使应用程序显示在菜单:// PCManFM的应用程序中?

来自分类Dev

如何在MonoDevelop的应用程序输出窗格中显示应用程序输出?

来自分类Dev

如何使从 .tar 手动提取的应用程序在“显示应用程序”中可用?

来自分类Dev

如何在我的应用程序中显示关系?

来自分类Dev

如何在Lubuntu中全屏显示应用程序?

来自分类Dev

如何在Java Swing应用程序中显示地图?

来自分类Dev

如何显示网络应用程序中的所有分数?

来自分类Dev

如何在Lubuntu中全屏显示应用程序?

来自分类Dev

如何在WPF应用程序中显示动态菜单

来自分类Dev

如何在您的应用程序中显示特殊字符?

来自分类Dev

如何在Android应用程序中显示弹出广告?

Related 相关文章

  1. 1

    jQuery移动应用程序标头在某些手机中以整页显示

  2. 2

    如何始终在flutter应用程序中始终静态显示从Firebase存储下载的图像,单击即可打开并查看

  3. 3

    如何在Android应用中显示整页广告

  4. 4

    如何在react-native中更改应用程序的显示名称

  5. 5

    如何让Emotion / Rollup / Typescript组件CSS显示在使用的React应用程序中?

  6. 6

    如何在React + socket io应用程序中显示聊天

  7. 7

    如何在 React Native 应用程序中显示 git-describe?

  8. 8

    如何使用 React 在浏览器中显示控制台应用程序?

  9. 9

    如何在 React 应用程序中显示彩色 STL 文件

  10. 10

    无论如何,React 应用程序都没有显示在 Codepen 中?

  11. 11

    如何始终在特定的显示器上启动应用程序?

  12. 12

    osx:如何使cmd-tab(应用程序切换器)菜单始终显示?

  13. 13

    “ cf应用程序”始终显示0.0%的cpu-如何测量该值?

  14. 14

    应用程序始终显示在Ubuntu 16.04中的第三位

  15. 15

    任何应用程序的菜单栏都应始终显示

  16. 16

    即使退出应用程序,如何在菜单栏中显示应用程序图标

  17. 17

    如何避免我的android应用程序显示在“最近的应用程序”列表中?

  18. 18

    如何在Win RT应用程序中的应用程序级别显示进度条?

  19. 19

    如何使应用程序显示在菜单:// PCManFM的应用程序中?

  20. 20

    如何在MonoDevelop的应用程序输出窗格中显示应用程序输出?

  21. 21

    如何使从 .tar 手动提取的应用程序在“显示应用程序”中可用?

  22. 22

    如何在我的应用程序中显示关系?

  23. 23

    如何在Lubuntu中全屏显示应用程序?

  24. 24

    如何在Java Swing应用程序中显示地图?

  25. 25

    如何显示网络应用程序中的所有分数?

  26. 26

    如何在Lubuntu中全屏显示应用程序?

  27. 27

    如何在WPF应用程序中显示动态菜单

  28. 28

    如何在您的应用程序中显示特殊字符?

  29. 29

    如何在Android应用程序中显示弹出广告?

热门标签

归档