如何使网站标题响应?

时间:2018-09-13 11:03:07

标签: css html5 css3 flexbox bootstrap-4

我有一个标题,其中包含导航栏,徽标和简短说明。

我需要怎么做才能使其具有响应能力?导航栏还可以(汉堡图标),但是我的解决方案看起来与下面的可视图形不同。

这是一个JSFiddle:http://jsfiddle.net/Mwanitete/4f6d7emr/10/

在小视口中显示时,我可以看到以下内容:

enter image description here

/* Marketing business main header */

.marketing-navbar_items {
  font-family: Helvetica Neue;
  font-size: 30px;
  font-weight: normal;
  color: #FFFFFF;
}

.marketing-main-header_banner {
  background-image: url("https://svgshare.com/i/8KR.svg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: right -199px bottom;
  position: relative;
  height: 949px;
}

.marketing-main-header_details {
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
  margin-top: 30px;
}

.marketing-main-header_description p {
  font-size: 30px;
  font-family: HeaderFont;
  color: white;
  /* width: 55%; */
  text-align: center;
  margin: 50px 0px;
}

.marketing-main-header_button-primary {
  background-color: white;
  background-size: 150px 100px;
  font-size: 16px;
  border-color: transparent;
  color: #4834D4;
  font-family: Roboto Regular;
  width: 373px;
  height: 92px;
}

.marketing-main-header_button {
  margin-top: 50px;
}

@media only screen and (min-width: 375px) and (max-width: 768px) {
  img {
    width: 100%;
  }
}

.marketing-main-header_logo img {
  width: 100%;
  margin: 0px;
  padding: 0px;
}


}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

<div class="container-fluid marketing-main-header">
  <div class="marketing-main-header_banner">
    <nav class="navbar navbar-expand-lg navbar-light">
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav ml-auto marketing-navbar">
          <li class="marketing-navbar_items  nav-item">
            <a class="marketing-nav-link nav-link" href="#">Dla kogo </a>
          </li>
          <li class="marketing-navbar_items nav-item">
            <a class="marketing-nav-link nav-link" href="#">Agenda</a>
          </li>
          <li class="marketing-navbar_items nav-item">
            <a class="marketing-nav-link nav-link" href="#">Prowadzacy</a>
          </li>
          <li class="marketing-navbar_items nav-item">
            <a class=" marketing-nav-link nav-link " href="#">Faq</a>
          </li>
          <li class="marketing-navbar_items nav-item">
            <a class="marketing-nav-link nav-link " href="#">Kontakt</a>
          </li>
          <li class="marketing-navbar_items nav-item">
            <a class="marketing-nav-link nav-link " href="#">Kompetencje</a>
          </li>
        </ul>
      </div>
    </nav>


    <div class="marketing-main-header_details">
      <div class="marketing-main-header_logo">
        <img src="https://thumb.ibb.co/hPrhZp/logo_mib.png">
      </div>
      <div class="marketing-main-header_title">
        <h1>SZKOLENIA</h1>
      </div>
      <div class="marketing-main-header_description">
        <p>Lorem ipsum dolor sit amet, an pro dicta maiorum recusabo.</p>
      </div>
      <div class="marketing-main-header_sub-description">
        <p>Lorem ipsum dolor sit amet, an pro dicta maiorum recusabo.</p>
      </div>

      <div class="marketing-main-header_button">
        <button type="button" class="marketing-main-header_button-primary">Poznaj Agende</button>
      </div>
    </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:1)

我改变了你的封锁

.marketing-main-header_banner
{
    background-image: url("https://svgshare.com/i/8KR.svg");
    background-size: cover;
    background-repeat: no-repeat;
    background-position: right -199px bottom;
    position: relative;
    height: 949px;
}

.marketing-main-header_banner
{
    background-image: url("https://svgshare.com/i/8KR.svg");
    background-size: auto 1199px;
    background-repeat: no-repeat;
    background-position: center -250px;
    position: relative;
    height: 949px;
}

它非常接近您想要实现的目标。

问题是您使用“ cover”作为尺寸,它将始终尝试将至少其中一个尺寸适合您的背景。由于应削减background-width并且background-height太小,以至于边缘超出可见部分,因此您必须将background的高度设置为大于元素的高度,以迫使其左右溢出。 最后一件事是将背景推到顶部偏移一点。

我选择250像素将其添加到背景高度并作为偏移量,因为这是目前最好的选择。您可能需要稍微调整一下。

http://jsfiddle.net/4f6d7emr/20/

请记住,这仅是显示汉堡的较小显示屏的解决方案。您可以将其添加到使用媒体屏幕的响应式CSS文件中。