RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 782644
Accepted
Дмитрий Сухоцкий
Дмитрий Сухоцкий
Asked:2020-02-09 18:13:58 +0000 UTC2020-02-09 18:13:58 +0000 UTC 2020-02-09 18:13:58 +0000 UTC

裁剪背景图像

  • 772

在此处输入图像描述

告诉。将图片放在背景中。屏幕缩小时,图片要保持比例,高度等于“header-section”的高度,右边多余的部分要剪掉,不显示。你能解释一下吗。

*{
    margin: 0;
    padding: 0;
    font-size: 10px;
}

/*-------------------------------------- header ---------------------------- */
.header-menu-col {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
}
.header-section {
    background-color: #e9e9e9;
    padding: 30px 0 90px ;  
}
.header-section .img-bg{
    background-repeat: no-repeat;
    opacity: .1;
    position: absolute;
    top: 0px;
}
.header-section .menu ul{
    display: flex;
    list-style-type: none;
}
.header-section .menu ul a{
    text-decoration: none;
    padding: 0 15px;
    color: #191919;
    font-family: "Montserrat";
    font-size: 12px;
    font-weight: bold;
    line-height: 24px;
    text-transform: uppercase;
}
.header-section .menu ul a:hover {
    color: #10c9c3;  
}
.header-section .menu ul a.active{
    color: #10c9c3;
    letter-spacing: 1.2px;
}
.caption-header {
    justify-content: flex-end;
}
.caption-header h1{
    color: #1d1d1d;
    font-family: "Montserrat";
    font-size: 38px;
    font-weight: bold;
    line-height: 48px;
}
.caption-header p{
    color: #787878;
    font-family: "Nunito Sans";
    font-size: 18px;
    font-weight: 400;
    line-height: 28px;
    padding: 25px 0;
}
.caption-header-row {
    justify-content: flex-end;
    margin-top: 150px;
}
.caption-header-row a{
    padding: 20px 40px;
    background-color: #10c9c3;
    color: #FFF;
    font-family: "Montserrat";
    font-size: 12px;
    font-weight: 500;
    line-height: 84px;
    text-transform: uppercase;
    letter-spacing: 1.2px; 
    text-decoration: none;
}
.caption-header-row a:hover {
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

@media (max-width: 768px) {
    .menu {
        display: none;
    }
    .caption-header-row {
        margin-top: 50px;
    }
    .header-menu-col {
        justify-content: center;
    }
    .caption-header {
        text-align: center;
    }
}
@media (max-width: 568px) {
    .header-section .img-bg{
        
        overflow: hidden;
    }
}
/*-------------------------------------- /header ---------------------------- */
/*-------------------------------------- about ---------------------------- */
.about-section {
    padding: 50px 0; 
    text-align: center;  
    
}
.about-section h1 {
    color: #191919;
    font-family: Montserrat;
    font-size: 30px;
    font-weight: bold;
    line-height: 60px;
}
.about-section p {
    color: #787878;
    font-family: "Nunito Sans";
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    padding: 25px 0;
}
@media (max-width: 768px) {
    .about-section p {
        font-size: 14px;
}
/*-------------------------------------- /about ---------------------------- */
<!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
         <meta name="viewport" content="initial-scale=1"  content="width=device-width"> 
         <link rel="stylesheet"  href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
         <link href="https://fonts.googleapis.com/css?family=Montserrat|Raleway" rel="stylesheet">
         <link rel="stylesheet" type="text/css" href="style/style.css">
  
</head>
   <body>
        <div id="header" class="header-section">
          <img src="https://preview.ibb.co/eG0rvc/header_bg.jpg" alt="header_bg" border="0" class="img-bg">
          <div class="container">
            <div class="row">
              <div class="col-xl-12 header-menu-col">
                <div class="logo">
                  <a href="#"><img src="image/logo.png" width="31px" height="25px" alt="logo"></a>
                </div>
                <div class="menu">
                  <ul>
                      <li class="menu-item"><a  class="active" href="#home">home</a></li>
                      <li class="menu-item"><a  href="#about">about</a></li>
                      <li class="menu-item"><a  href="#work">work</a></li>
                      <li class="menu-item"><a  href="#process">process</a></li>
                      <li class="menu-item"><a  href="#services">services</a></li>
                      <li class="menu-item"><a  href="#testcontact">testcontact</a></li>
                      <li class="menu-item"><a  href="#contact">Contact</a></li>
                  </ul>
                </div><!-- /============================= /menu =========================== !-->
              </div><!-- /============================= /col logo =========================== !-->
            </div>
            <div class="row caption-header-row">
              <div class="col-sm-12 col-md-6">
                <div class="caption-header">
                  <h1>We Design and Develop</h1>
                  <p>We are a new design studio based in USA. We have over 
                      20 years of combined experience, and know a thing or two 
                      about designing websites and mobile apps.</p>
                  <a href="#">contact us</a>
                </div>
              </div><!-- /============================= /col menu =========================== !-->
            </div><!-- /============================= /row =========================== !-->
          </div><!-- /============================= /container =========================== !-->
        </div><!-- /============================= /header-section =========================== !-->
        <div id="about" class="about-section">
            <div class="container">
              <div class="row justify-content-center">
                <div class="col-sm-12 col-md-12">
                  <div class="caption-about">
                    <h1>Abous us</h1>
                    <p>Divide have don't man wherein air fourth. Own itself make have night won't make.<br> 
                        A you under Seed appear which good give. Own give air without fowl moveth dry first<br>
                        heaven fruit, dominion she'd won't very all.</p>
                    <img src="image/signature.png" alt="about us">
                  </div>
                </div><!-- /============================= /col  =========================== !-->
              </div><!-- /============================= /row =========================== !-->
            </div><!-- /============================= /container =========================== !-->
        </div><!-- /============================= /about-section =========================== !-->       
        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
    </body>
</html>

html
  • 1 1 个回答
  • 10 Views

1 个回答

  • Voted
  1. Best Answer
    Puvvl
    2020-02-09T18:20:27Z2020-02-09T18:20:27Z

    添加到样式:

    .header-section {
      overflow: hidden;
      position: relative;
    }
    
    .header-section .img-bg {
      height: 100%;
    }
    

      * {
      margin: 0;
      padding: 0;
      font-size: 10px;
    }
    
    
    /*-------------------------------------- header ---------------------------- */
    
    .header-menu-col {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      margin-top: 40px;
    }
    
    .header-section {
      background-color: #e9e9e9;
      padding: 30px 0 90px;
      overflow: hidden;
      position: relative;
    }
    
    .header-section .img-bg {
      background-repeat: no-repeat;
      opacity: .1;
      position: absolute;
      top: 0px;
      height: 100%;
    }
    
    .header-section .menu ul {
      display: flex;
      list-style-type: none;
    }
    
    .header-section .menu ul a {
      text-decoration: none;
      padding: 0 15px;
      color: #191919;
      font-family: "Montserrat";
      font-size: 12px;
      font-weight: bold;
      line-height: 24px;
      text-transform: uppercase;
    }
    
    .header-section .menu ul a:hover {
      color: #10c9c3;
    }
    
    .header-section .menu ul a.active {
      color: #10c9c3;
      letter-spacing: 1.2px;
    }
    
    .caption-header {
      justify-content: flex-end;
    }
    
    .caption-header h1 {
      color: #1d1d1d;
      font-family: "Montserrat";
      font-size: 38px;
      font-weight: bold;
      line-height: 48px;
    }
    
    .caption-header p {
      color: #787878;
      font-family: "Nunito Sans";
      font-size: 18px;
      font-weight: 400;
      line-height: 28px;
      padding: 25px 0;
    }
    
    .caption-header-row {
      justify-content: flex-end;
      margin-top: 150px;
    }
    
    .caption-header-row a {
      padding: 20px 40px;
      background-color: #10c9c3;
      color: #FFF;
      font-family: "Montserrat";
      font-size: 12px;
      font-weight: 500;
      line-height: 84px;
      text-transform: uppercase;
      letter-spacing: 1.2px;
      text-decoration: none;
    }
    
    .caption-header-row a:hover {
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    }
    
    @media (max-width: 768px) {
      .menu {
        display: none;
      }
      .caption-header-row {
        margin-top: 50px;
      }
      .header-menu-col {
        justify-content: center;
      }
      .caption-header {
        text-align: center;
      }
    }
    
    @media (max-width: 568px) {
      .header-section .img-bg {
        overflow: hidden;
      }
    }
    
    
    /*-------------------------------------- /header ---------------------------- */
    
    
    /*-------------------------------------- about ---------------------------- */
    
    .about-section {
      padding: 50px 0;
      text-align: center;
    }
    
    .about-section h1 {
      color: #191919;
      font-family: Montserrat;
      font-size: 30px;
      font-weight: bold;
      line-height: 60px;
    }
    
    .about-section p {
      color: #787878;
      font-family: "Nunito Sans";
      font-size: 16px;
      font-weight: 400;
      line-height: 24px;
      padding: 25px 0;
    }
    
    @media (max-width: 768px) {
      .about-section p {
        font-size: 14px;
      }
      /*-------------------------------------- /about ---------------------------- */
    <!doctype html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="initial-scale=1" content="width=device-width">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
      <link href="https://fonts.googleapis.com/css?family=Montserrat|Raleway" rel="stylesheet">
      <link rel="stylesheet" type="text/css" href="style/style.css">
    
    </head>
    
    <body>
      <div id="header" class="header-section">
        <img src="https://preview.ibb.co/eG0rvc/header_bg.jpg" alt="header_bg" border="0" class="img-bg">
        <div class="container">
          <div class="row">
            <div class="col-xl-12 header-menu-col">
              <div class="logo">
                <a href="#"><img src="image/logo.png" width="31px" height="25px" alt="logo"></a>
              </div>
              <div class="menu">
                <ul>
                  <li class="menu-item"><a class="active" href="#home">home</a></li>
                  <li class="menu-item"><a href="#about">about</a></li>
                  <li class="menu-item"><a href="#work">work</a></li>
                  <li class="menu-item"><a href="#process">process</a></li>
                  <li class="menu-item"><a href="#services">services</a></li>
                  <li class="menu-item"><a href="#testcontact">testcontact</a></li>
                  <li class="menu-item"><a href="#contact">Contact</a></li>
                </ul>
              </div>
              <!-- /============================= /menu =========================== !-->
            </div>
            <!-- /============================= /col logo =========================== !-->
          </div>
          <div class="row caption-header-row">
            <div class="col-sm-12 col-md-6">
              <div class="caption-header">
                <h1>We Design and Develop</h1>
                <p>We are a new design studio based in USA. We have over 20 years of combined experience, and know a thing or two about designing websites and mobile apps.</p>
                <a href="#">contact us</a>
              </div>
            </div>
            <!-- /============================= /col menu =========================== !-->
          </div>
          <!-- /============================= /row =========================== !-->
        </div>
        <!-- /============================= /container =========================== !-->
      </div>
      <!-- /============================= /header-section =========================== !-->
      <div id="about" class="about-section">
        <div class="container">
          <div class="row justify-content-center">
            <div class="col-sm-12 col-md-12">
              <div class="caption-about">
                <h1>Abous us</h1>
                <p>Divide have don't man wherein air fourth. Own itself make have night won't make.<br> A you under Seed appear which good give. Own give air without fowl moveth dry first<br> heaven fruit, dominion she'd won't very all.</p>
                <img src="image/signature.png" alt="about us">
              </div>
            </div>
            <!-- /============================= /col  =========================== !-->
          </div>
          <!-- /============================= /row =========================== !-->
        </div>
        <!-- /============================= /container =========================== !-->
      </div>
      <!-- /============================= /about-section =========================== !-->
      <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
    </body>
    
    </html>

    • 0

相关问题

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    是否可以在 C++ 中继承类 <---> 结构?

    • 2 个回答
  • Marko Smith

    这种神经网络架构适合文本分类吗?

    • 1 个回答
  • Marko Smith

    为什么分配的工作方式不同?

    • 3 个回答
  • Marko Smith

    控制台中的光标坐标

    • 1 个回答
  • Marko Smith

    如何在 C++ 中删除类的实例?

    • 4 个回答
  • Marko Smith

    点是否属于线段的问题

    • 2 个回答
  • Marko Smith

    json结构错误

    • 1 个回答
  • Marko Smith

    ServiceWorker 中的“获取”事件

    • 1 个回答
  • Marko Smith

    c ++控制台应用程序exe文件[重复]

    • 1 个回答
  • Marko Smith

    按多列从sql表中选择

    • 1 个回答
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Suvitruf - Andrei Apanasik 什么是空? 2020-08-21 01:48:09 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5