超大图像高度

时间:2018-06-26 07:42:36

标签: html css twitter-bootstrap css3 bootstrap-4

我的jumbotron图像是1,100 x687。但是,当我将图像添加到jumbotron时,img高度仅为310px。我想将高度增加到至少500(虽然在较小的设备上仍然可以响应)。我怎样才能做到这一点?

巨无霸语法:

.jumbotron{
    background-image: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url("../img/colorful_planke.jpg");
    background-size: cover;
}
<div class="jumbotron jumbotron-fluid jumbo_text">
    <div class="container"><br>
        <h1 class="display-4 font-weight-bold text-center">Sell More Online</h1><br>
        <p class="lead text-center font-weight-bold">Web Development | Web Design | Google Analytics | Online Advertising |
            Social Media Advertising</p>
        <br>
        <h2 class="text-center">Let's Make Your Business More Profitable!</h2>
    </div>
</div>

最后,如果要在主页上添加大图片,还是建议使用jumbotron,还是应该将其放在普通的.container中?

2 个答案:

答案 0 :(得分:2)

如果需要更大的min-height,请设置.jumbotron

.jumbotron {
  background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("http://lorempixel.com/1100/667/");
  background-size: cover;
  color: #fff;
  min-height: 500px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">

<div class="jumbotron jumbotron-fluid jumbo_text">
  <div class="container"><br>
    <h1 class="display-4 font-weight-bold text-center">Sell More Online</h1><br>
    <p class="lead text-center font-weight-bold">Web Development | Web Design | Google Analytics | Online Advertising | Social Media Advertising</p>
    <br>
    <h2 class="text-center">Let's Make Your Business More Profitable!</h2>
  </div>
</div>

答案 1 :(得分:0)

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  <title>Bootstrap 101 Template</title>

  <!-- Bootstrap -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
  <div class="container-fluid">
    <div class="row">
      <div class="jumbotron">
        <h1>Hello, world!</h1>
        <p>...</p>
        <p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a></p>
      </div>
    </div>
  </div>

  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <!-- Include all compiled plugins (below), or include individual files as needed -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>

</html>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  <title>Bootstrap 101 Template</title>

  <!-- Bootstrap -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
  <div class="container-fluid">
    <div class="row">
      <div class="jumbotron">
      <div class=text-center >
        <h1>Sell More Online</h1>
        </div>
        <p class="lead text-center font-weight-bold">Web Development | Web Design | Google Analytics | Online Advertising | Social Media Advertising</p>
        <br>
        <h2 class="text-center">Let's Make Your Business More Profitable!</h2>
      </div>
    </div>
  </div>
  </div>

  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <!-- Include all compiled plugins (below), or include individual files as needed -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>

</html>