响应式Bootstrap登录表单

时间:2018-04-16 17:07:53

标签: html css responsive-design bootstrap-4 responsive

我正在使用bootstrap为我的Web应用程序构建一个用于样式的登录表单。我使用了下面的" Meta Tag"使屏幕响应

<meta name="viewport" content="width=device-width, initial-scale=1.0">

和网格系统的多个bootstraps col类组合但无济于事。

<style>
.overlay {
    /* Height & width depends on how you want to reveal the overlay (see JS below) */
    height: 100%;
    width: 0;
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    background-color: rgb(0,0,0); /* Black fallback color */
    background-color: rgba(51, 51, 255, 0.9); /* Black w/opacity */
    overflow-x: hidden; /* Disable horizontal scroll */
    transition: 0.5s; /* 0.5 second transition effect to slide in or slide down the overlay (height or width, depending on reveal) */
}

/* Position the content inside the overlay */
.overlay-content {
    position: relative;
    top: 20%; /* 25% from the top */
    width: 100%; /* 100% width */
    text-align: center; /* Centered text/links */
    margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
}

/* The navigation links inside the overlay */
.overlay a {
    padding: 8px;
    text-decoration: none;
    font-size: 36px;
    color: #818181;
    display: block; /* Display block instead of inline */
    transition: 0.3s; /* Transition effects on hover (color) */
}

/* When you mouse over the navigation links, change their color */
.overlay a:hover, .overlay a:focus {
    color: #f1f1f1;
}

/* Position the close button (top right corner) */
.overlay .closebtn {
    position: absolute;
}

/* When the height of the screen is less than 450 pixels, change the font-size of the links and position the close button again, so they don't overlap */
@media screen and (max-height: 450px) {
    .overlay a {font-size: 20px}
    .overlay .closebtn {
        font-size: 40px;
        top: 15px;
        right: 35px;
    }
}

<div id="myNav" class="overlay">
  <div class="overlay-content">
    <div class="container">
      <div class="row">
        <div class="col-12"> // column which contains the login form code
          <div id="loginform">
            // login form code
          </div>
          <div id="signupform">
        // signup form code 
            </div>
        </div>
      </div>
    </div>
  </div>

这是我的输出 - Output Image

欣赏任何关于我做错了什么的见解以及如何解决这个问题。

非常感谢。

2 个答案:

答案 0 :(得分:0)

尝试使用 form-group 类,而不是登录表单和注册表单。 它可以使网络形式移动响应。

检查:Bootstrap Form Document

答案 1 :(得分:0)

我提供这个作为答案,因为发表评论太过分了。

确保您使用<!doctype html>

为了确保Bootstrap 4在Safari中正常运行,请使用shrink-to-fit=no - 请参阅What does the shrink-to-fit viewport meta attribute do?

使用text-center的引导类而不是HTML属性align - 请参阅Text - Bootstrap

由于您的课程总是根据您的示例获得col-XX-12,因此请使用col-12。见Grid system

如上例所示,这是一个使用form-group的好地方 - 请参阅Forms - Boostrap

总体而言,请从Introduction - Bootstrap

开始
<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>


<body>
<div class="col-12 text-center"> // column which contains the login form code
  <div id="loginform">
  // login form code
  </div>
  <div id="signupform">
    // signup form code 
  </div>
</div>

</body>
</html>