如何使行高延伸到容器的剩余高度?

时间:2020-05-24 08:07:39

标签: css bootstrap-4 flexbox

这是我的代码:

<!doctype html>
	<html lang="en" class="h-100">
		<head>
			<!-- Required meta tags -->
			<meta charset="utf-8">
			<meta name="viewport" content="width=device-width, initial-scale=1,shrink-to-fit=no">

			<!-- Bootstrap CSS -->
			<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
			<!-- Optional JavaScript -->
			<!-- jQuery first, then Popper.js, then Bootstrap JS -->
			<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
			<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
			<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
			<style>
				video{
					object-fit:cover;
				}
			</style>	
		</head>
		<body class="container-fluid p-1 h-100">
			<div class="container-fluid h-100 border border-primary p-1">
				<div class="row border border-danger h-50 p-0 no-gutters">
					<div class="col p-0 position-relative">
						<video id="selfView" class="h-100 w-100 position-absolute" controls></video>
					</div>
				</div>
				<div class="row p-0 border border-danger no-gutters d-flex flex-row">
					<div class="d-flex flex-row justify-content-center col p-1 border border-success">
						<div class="btn-group-toggle p-1" data-toggle="buttons">
						  <label class="btn btn-sm btn-lg btn-success">
							Share Video:<span class="badge badge-success">On</span>
							<input type="checkbox" id="shareVideo" checked>
						  </label>
						</div>
						<div class="btn-group-toggle p-1" data-toggle="buttons">
						  <label class="btn-sm btn btn-lg btn-success">
							Share Audio:<span class="badge badge-success">On</span>
							<input type="checkbox" id="shareAudio" checked>
						  </label>
						</div>
						<div class="btn-group-toggle p-1" data-toggle="buttons">
						  <label class="btn-sm btn btn-lg btn-danger">
							Share Screen:<span class="badge badge-danger">Off</span>
							<input type="checkbox" id="shareScreen">
						  </label>
						</div>
					</div>
				</div>
				<div class="row no-gutters d-flex justify-content-center border border-success p-1">
					<div class="col p-0 d-flex flex-row justify-content-center">
						<button class="btn-sm btn btn-lg btn-success">Create a meeting</button>
					</div>	
				</div>
				<div class="row no-gutters d-flex justify-content-center border border-warning p-0 flex-grow-1 flex-shrink-0">
					<div class="col p-0 d-flex flex-row justify-content-center overflow-auto">
						dds
					</div>	
				</div>
			</div>

		</body>
	</html>

我试图将“ flex-grow-1”和“ flex-shrink-0”类都添加到该行中。

不幸的是,它不起作用。黄色边框行不会将其高度扩展到剩余的容器空间。

我是新手,是否有些设置没有正确设置?

1 个答案:

答案 0 :(得分:0)

经过几次尝试,我找到了解决方法:

<!doctype html>
<html lang="en" class="h-100">

  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
    <style>
      video {
        object-fit: cover;
      }

    </style>
  </head>

  <body class="container-fluid p-1 h-100">
    <div class="container-fluid h-100 border border-primary p-1">
      <div class="row border border-danger h-50 p-0 no-gutters">
        <div class="col p-0 position-relative">
          <video id="selfView" class="h-100 w-100 position-absolute" controls></video>
        </div>
      </div>
      <div class="row border border-info p-0 no-gutters h-50 ">
        <div class="col border border-warning p-0 d-flex flex-column">
          <div class="row border border-dark p-0 no-gutters">
            <div class="d-flex flex-row justify-content-center col p-1 border border-success">
              <div class="btn-group-toggle p-1" data-toggle="buttons">
                <label class="btn btn-sm btn-lg btn-success">
                  Share Video:<span class="badge badge-success">On</span>
                  <input type="checkbox" id="shareVideo" checked>
                </label>
              </div>
              <div class="btn-group-toggle p-1" data-toggle="buttons">
                <label class="btn-sm btn btn-lg btn-success">
                  Share Audio:<span class="badge badge-success">On</span>
                  <input type="checkbox" id="shareAudio" checked>
                </label>
              </div>
              <div class="btn-group-toggle p-1" data-toggle="buttons">
                <label class="btn-sm btn btn-lg btn-danger">
                  Share Screen:<span class="badge badge-danger">Off</span>
                  <input type="checkbox" id="shareScreen">
                </label>
              </div>
            </div>
          </div>
          <div class="row border border-dark p-0 no-gutters">
            <div class="col p-1 d-flex flex-row justify-content-center">
              <button class="btn-sm btn btn-lg btn-success">Create a meeting</button>
            </div>
          </div>
          <div class="row border border-dark p-0 no-gutters flex-grow-1 position-relative">
            <div class="col p-0 border border-secondary position-absolute h-100 overflow-auto">
              sdfsdf<br>
              sdfsdf<br>
              sdfsdf<br>
              sdfsdf<br>

              sdfsdf<br>
              sdfsdf<br>
              sdfsdf<br>
              sdfsdf<br>

              sdfsdf<br>
              sdfsdf<br>
              sdfsdf<br>
              sdfsdf<br>

              sdfsdf<br>
              sdfsdf<br>
              sdfsdf<br>
              sdfsdf<br>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>

</html>