无法获得联系表单以响应css的中心

时间:2018-04-05 21:45:31

标签: html css

我已经在线查看并尝试了不同的操作,以便在屏幕变小或变小时使联系表单居中。标题和导航栏是响应式的,联系表单不是。此外,我的代码在这里分为两个单独的表,然后网站随机组合它们。如果你知道如何,你可以将它们分开。

body {
  margin: 0;
  padding: 0;
  font-family: 'arial', serif;
}

.nav {
  background-color: #ffb6c1;
  color: #ffffff list-style: none;
  text-align: center;
  padding: 20px 0 20px 0;
}

img {
  max-width: auto max-height: auto;
}

.nav>li {
  display: inline-block;
  padding-right: 50px;
  font-size: 16px;
}

.nav>li>a {
  text-decoration: none;
  color: #ffffff
}

.nav>li>a:hover {
  color: #C0C0C0
}

.banner {
  width: 100;
  display: block;
}

.banner>.bannerimage {
  width: 100;
  height: 100;
  display: block;
}

ul.nav {
  margin: 0;
}

.cognito {
  margin: 0 auto;
  width: 100px;
}
<!DOCTYPE>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="Events.css">
  <link rel="stylesheet" type="text/css" href="contactusmobile.css" media="screen and (max-width: 900px)">
</head>

<body>
  <div class="header">
    <img class="banner-image" src="ccc.png" width="100%" height="150px">
  </div>
  <ul class="nav">
    <li><a href="Home.html">Home</a></li>
    <li><a href="Aboutus.html">About Us</a></li>
    <li><a href="Menu.html">Menu</a></li>
    <li><a href="entertowin.html">Enter to Win</a></li>
    <li><a href="Merchandise.html">Merchandise</a></li>
    <li><a href="events.html">Events</a></li>
    <li><a href="contactus.html">Contact Us</a></li>
  </ul>
  <style>
    .cognito {
      position: absolute;
      margin-top: 20px;
      margin-left: 450px;
    }
    
    body {
      background: url('heartcoffee.jpeg');
      background-repeat: no-repeat;
      background-size: 2000px 1000px;
    }
  </style>
  <div class="cognito">
    <script src="https://services.cognitoforms.com/s/q8sF4QFeokuqNI1bQZm3vg">
    </script>
    <script>
      Cognito.load("forms", {
        id: "1"
      });
    </script>
  </div>
</body>

</html>

1 个答案:

答案 0 :(得分:0)

发布问题请求的所有代码都没用。 但是,对于div中容器的中心,您可以使用:

.center{
margin:0 auto;
}

否则在位置:相对; 容器:

.center{
position:absolute;
left:50%;
transform:translateX(-50%);
top:0;
}