如何使<hr />标签具有响应性?

时间:2019-04-20 04:07:16

标签: html css responsive-design bootstrap-4

我使用html css和bootstrap创建了一个页面。而且我在水平线标签方面遇到问题。当窗口大小更改为较小时,需要帮助来解决此问题

当我给hr标签提供400px的分辨率时,它在全屏模式下效果很好,但是当屏幕尺寸减小到小于500px的移动尺寸时,效果并不理想,因此我尝试使用90%的宽度,然后可以正常工作小屏幕,但是当屏幕小于或等于小屏幕时,它会在水平方向上占用我不希望的空间。

body {
  color: white;
  font-family: Lato;
  background: url(purrfectimage.jpg);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

#content {
  text-align: center;
  padding-top: 25%;
  text-shadow: 0px 4px 3px rgba(0, 0, 0, 0.4), 0px 8px 13px rgba(0, 0, 0, 0.1), 0px 18px 23px rgba(0, 0, 0, 0.1);
}

hr {
  width: 400px;
  border-top: 1px solid #f8f8f8;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

h1 {
  font-weight: 700;
  font-size: 5em;
}

html {
  height: 100%;
  width: 100%;
}

.custom-toggler.navbar-toggler {
  border-color: rgb(255, 255, 255);
}
<!DOCTYPE html>
<html>

<head>

  <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no;">

  <title>Purrfect Match</title>

  <link href="https://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet">

  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>

  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

  <link rel="stylesheet" href="
    https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

  <link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

  <link rel="stylesheet" type="text/css" href="purr.css">

</head>

<body>
  <div class="container">
    <div class="row">
      <div class="col-lg-12">
        <div id="content">
          <h1>Purrfect Match</h1>
          <h3>The Only Human-Feline Dating App</h3>
          <hr>
          <button type="button" class="btn btn-light btn-lg"><i class="fa fa-paw" aria-hidden="true"></i> Get Started!</button>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

我实际上希望当我调整窗口大小时,水平线应该与全窗口甚至小断点时显示的相同。

1 个答案:

答案 0 :(得分:1)

您好,欢迎来到Stackoverflow。尝试看看这个站点,您可以在其中了解vwvh,它们是与屏幕大小有关的单位:)

https://www.w3schools.com/CSSref/css_units.asp