带 Bootstrap Reactstrap 的全高列

use*_*919 4 twitter-bootstrap reactjs reactstrap

我正在使用 React 和 Reactstrap 创建一些模板。这就是我的代码现在的样子:

import React, { Component } from 'react';
import { Container, Row, Col } from 'reactstrap';

const styles = {
  container: {

  },
  right: {
    height: window.innerHeight, // I want to change this
    padding: 0,
    margin: 0,
    overflow: 'hidden',
    backgroundColor: 'yellow'
  },
  left: {
    overflowY: '100%',
    padding: 0,
    height: window.innerHeight,
    paddingBottom: '50px',
    backgroundColor: 'white'
  },
  row: {
    marginBottom: 0
  }
}

class MainArea extends Component {
  constructor(){
   super();
  }
  render() {
   return (
     <Container fluid>
      <Row>
       <Col xs="12" sm="4" md="4" lg="3" style={ styles.left }>
           Some text
       </Col>
       <Col xs="12" sm="8" md="8" lg="9" style={ styles.right }>
           Some text
       </Col>
      </Row>
     </Container>
   );
 }
}

export default MainArea;
Run Code Online (Sandbox Code Playgroud)

现在我得到了完整的高度(自动调整大小的列),但我在我的 CS 中使用了这段 JS 代码:

  height: window.innerHeight, 
Run Code Online (Sandbox Code Playgroud)

我不喜欢在CSS中使用JS,但我不知道如何在reactstrap库中做到这一点。

有任何想法吗?

小智 5

也许你可以使用 css 视口单元“vh”:

height: 100vh
Run Code Online (Sandbox Code Playgroud)

https://www.w3schools.com/cssref/css_units.asp

不过,请检查浏览器支持,它们可能无法在较旧的 iOS 设备上运行: https: //caniuse.com/#search=vh