score:0
what you're asking is more of a "make my div block have the full window or parentdomelement height" than "how to make reactcomponent have the full window or parentdomelement height".
here's a post that explains this: css - expand float child div height to parent's height
the gist of it is that the parent element's position
needs to be relative
. then, the child (i.e. the element you're trying to make have a height of 100% of its container) will actually have a height
of 100% of its container.
here's a demo:
<body>
<div id="title"></div>
<div class="parent">
<div class="child">
hi, i am a child
</div>
</div>
</body>
<style type="text/css">
.parent {
position: relative;
background-color: rgba(50, 70, 200, 0.3);
width: 100%;
height: 200px;
}
.child {
height: 100%;
background-color: rgba(50, 70, 200, 0.3);
}
</style>
with that, you just need to render your react component inside of the .parent
div and should work.
score:0
var rootstyle = {
backgroundcolor : 'green',
color : 'white',
height : '100vh'
}
or
var rootstyle = {
position: absolute,
top: 0,
left: 0,
right: 0,
bottom: 0
}
score:0
var rootstyle = {
backgroundcolor : 'green',
color : 'white',
height : '100%'
}
here you apply this style into only div section so for that you need in include "backgroundcolor" property into app.css
class app extends component {
render() {
return (
<div style={rootstyle}> // this style apply only its div not full screen
<poll />
</div>
);
}
}
app.css
html,body{backgourd:green}
score:2
while answers above might work. the code below solved the issue for me. then you can style what is inside the app component the way you want.
html, body, body > div, .app {
height: 100%;
}
score:5
the problem is not react. react just gets the html to the page.
the problem is that your body
element is only as big as its content. one way around this is to add this to your css:
html, body {
width: 100%;
height: 100%;
}
something similar here
score:12
make the div 100% of the viewport height.
var rootstyle = {
height: '100vh',
min-height : '100vh'
}
Source: stackoverflow.com
Related Query
- ReactJS Styling a Component to take full screen with background color
- Set background image to full screen in Reactjs
- Change the background color of a screen with react native
- How to display an image in full screen background using reactJS and css?
- Change page background color with each route using ReactJS and React Router?
- How to set the background color of material ui drawer component with styled-components?
- Styling react-select component with CSS className in Reactjs
- Reactjs with material UI background color all page
- Conditionally set background color in React component with Tailwind CSS
- ReactJS change background color every X second in functional component
- How to render a div component multiple times with different background color and text in React?
- cant get background image on full screen size in reactjs
- Full Screen Component ReactJS
- React Material UI menu items with different background colors - RAL color selector component
- reactjs background image not coming on full screen
- ReactJS component names must begin with capital letters?
- React - Component Full Screen (with height 100%)
- ReactJS - Pass props with Redirect component
- Upload File Component with ReactJS
- Change root background color with Material-UI theme
- How to pass props to Screen component with a tab navigator?
- ReactJS component not rendering textarea with state variable
- How to avoid 'children with same key' when replacing state in ReactJs component
- How to update ReactJS component based on URL / path with React-Router
- 'A valid React element (or null) must be returned' error with one of the component in ReactJS
- Integrating Facebook Web SDK with ReactJS Component State
- Datatables.net with ReactJS, render a ReactJS component in a column
- Correct way of Creating multiple stores with mobx and injecting it into to a Component - ReactJs
- ReactJS component PropTypes - specify a function type with a set number parameters
- ReactJS TypeScript pure component with children
More Query from same tag
- Redux not updating store
- React - Invalid hook call. Hooks can only be called inside of the body of a function component
- Assets being served in development, but not production and getting "Uncaught SyntaxError: Unexpected token '<'"
- React Router Dom v6 render not redirecting
- Is it possible to change the displayName of a Context.Consumer?
- how to create multiple fields, having their number?
- Determine which hooks are being called
- Testing state gets set correctly within componentDidMount from an ajax call
- How to import react modules from an HTML file with no npm/webpack
- Different Events for mobile and desktop
- Cannot submit form data to DatoCMS using Gatsby.js
- change value of this.props.location.state in react route
- React loop array and rende object
- Cannot read properties of undefined (reading 'value') React Functional Components
- How can remove console.log in the production build of a React application created using create-react-app?
- Adding Routes to a React/Firebase app
- How to Test Private Routing with React & React-Router
- Uncaught TypeError: inst.render is not a function; react-google-maps
- how add react-loading in react bootstrap table
- How to Get Current Window height & width after change Orientation in React-Native?
- How to update state inside an addListener React Class Component
- How to render this JSON object in react js
- How to use React Router's Link with a variable pathname?
- in ReactJS How to enable mui snackbar only when login is success?
- useState not reading variable outside of if statement
- display an alert message if an option is selected while selecting other option
- Confused about the strange performance of useMemo Hook in React
- setState in React: How to create a variable the value for which is dependent on another variable's value
- React Application looking for static files which are not being accessed
- Whether I should use more than one store instances, when managing an elevator manager like app?