【问题标题】:Jumbotron Image HeightJumbotron 图像高度
【发布时间】:2018-06-27 22:25:52
【问题描述】:

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

Jumbotron 语法:

.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 中?

【问题讨论】:

  • 你使用什么版本的引导程序??
  • 我使用的是 Bootstrap 版本 4

标签: html twitter-bootstrap css bootstrap-4


【解决方案1】:

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

.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>

【讨论】:

    【解决方案2】:

    <!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>

    【讨论】:

      猜你喜欢
      • 2015-02-15
      • 1970-01-01
      • 2015-10-20
      • 1970-01-01
      • 2017-07-20
      • 1970-01-01
      • 2015-06-02
      • 2018-10-20
      • 2021-07-29
      相关资源
      最近更新 更多