响应式图像的响应式表格? - Bootstrap

时间:2015-07-08 13:30:05

标签: html css forms twitter-bootstrap

我正在尝试将一个表单放在一个响应式图像之上,我想让表单也响应并调整大小与图像相关

目前图像是响应式的,但我无法将图像粘贴在图像上的一个位置并在相同位置调整大小

这可能吗?

当前代码:http://www.codeply.com/go/FFgsRfictx

2 个答案:

答案 0 :(得分:1)

以下内容仅对应于您提供的页面的表单部分。

我删除了图像元素,并使用资源链接作为表单元素的背景图像。表单字段包含引导类。

已在表单元素上设置了最小高度,以防止背景图像过度失真。

HTML:

<!--- bootstrap style sheet -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />


<!-- form section -->
<section id="contact class" class="container content-section text-center">

  <h1 class="brand-heading">Contact</h1>

  <div class="container-fluid">
    <div class="row">
      <!--- 
        under the grid system, one row has can have 12 columns 
        we'll use 3 columns on each side for spacing,
        6 columns for the form.

        the form is done the bootstrap way, less the validation.
        you need to add in hte missing fields yourself.
      --->
      <div class="col-md-3"></div>
      <div class="col-md-6">
          <form id="responsiveForm" action="">

            <div class="form-group">
              <label for="name">Name:</label> 
              <input type="text" class="form-control" id="name" name="name"/>
            </div>
            <div class="form-group">
              <label for="email">Email:</label> 
              <input type="text" class="form-control" id="email" name="email"/>
            </div>
            <div class="form-group">
              <label for="occasion">Occasion:</label> 
              <input type="text" class="form-control" id="occasion" name="occasion"/>
            </div>
            <div class="form-group">
              <input type="submit" name="submit" class="form-control btn btn-primary" value="go"/>
            </div>

            </div>
          </form>
        </div>
      <div class="col-md-3"></div>
    </div>
  </div>

</section>

的CSS:

#responsiveForm{
  background-image: url("http://s02.justpaste.it/files/justpaste/d233/a9446587/playingcardtemplate_small.png");
  background-size: cover;
  background-size: 100% 100%;

  min-height: 650px;
  padding: 80px;
  padding-top: 120px;
}

Codepen

中查看

编辑:对图像有点想法。如果您想使用表单的背景。你应该首先填写表格,找出那个表格的大小,然后按照这个比例塑造你的形象。

答案 1 :(得分:0)

试试这样:

.formOuterContainer {
  position: relative;
}    

.formInnerContainer {
  position: absolute;
  left: 72px;
  right: 72px;
  top: 80px;
  bottom: 84px;

  display: flex;
  align-items: center;
  justify-content: center;
}