【问题标题】:Span image over multiple rows in form在表单中将图像跨越多行
【发布时间】:2017-01-02 21:48:50
【问题描述】:

我有一个关于尝试以水平引导形式将图像跨越多行的问题。目前的情况如下图所示: 但是,我希望左侧的个人资料图像跨越输入字段的多行。现在它出于某种原因将第二个输入字段向下推,我似乎无法理解它。我还没有真正体验过这一切。所以我有点卡住了。我似乎找到的所有解决方案都针对引导网格系统,并不真正适用于引导表单。有没有其他人有这方面的经验或知道如何做到这一点?当前的 sn-p 代码可以在下面找到。提前致谢!

<!-- Basic information -->
<h4>Algemeen</h4>
<img src="./img/profile-edit.png" class="col-sm-2 img-profile-edit col-profile"></img>
<form class="form-horizontal">
  <div class="form-group form-group-sm">
    <label for="name" class="col-sm-3">Voornaam:</label>
    <div class="col-sm-6">
      <input type="text" class="form-control" id="name">
    </div>
  </div>
  <div class="form-group form-group-sm ">
    <label for="surname" class="col-sm-3">Achternaam:</label>
    <div class="col-sm-6">
      <input type="text" class="form-control" id="surname">
    </div>
  </div>
  <div class="form-group form-group-sm">
    <label for="gender" class="col-sm-3">Geslacht:</label>
    <div class="col-sm-6" id="gender">
      <label class="radio-inline"><input type="radio" name="optman">Man</label>
      <label class="radio-inline"><input type="radio" name="optwomen">Vrouw</label>
    </div>
  </div>
  <div class="form-group form-group-sm">
    <label for="dob" class="col-sm-3">Geboortedatum:</label>
    <div class="col-sm-6">
      <input type="date" format="dd/MM/yyyy" class="form-control" id="dob">
    </div>
  </div>
</form>

以及相关的 CSS 类:

.img-profile-edit {
  border-radius:15%;
  overflow:hidden; 
}

@media (min-width: 768px) {
  .col-profile {
      float: right;
      padding: 0 5px;
  }
}

编辑:父 &lt;div&gt; 代码 sn-p 太多

【问题讨论】:

    标签: html css twitter-bootstrap twitter-bootstrap-form


    【解决方案1】:

    据我了解,您的问题应该看起来像下面的 sn-p。如果它未能满足您对某些原因的期望,请发表评论 - 我会尝试更改答案

    .img-profile-edit {
      border-radius:15%;
      overflow:hidden; 
    }
    
    @media (min-width: 768px) {
      .col-profile {
          float: right;
          padding: 0 5px;
      }
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <h4>Algemeen</h4>
    <div class="col-sm-10">
    <form class="form-horizontal">
      <div class="form-group form-group-sm">
        <div class="form-group form-group-sm">
          <label for="name" class="col-sm-3">Voornaam:</label>
          <div class="col-sm-6">
            <input type="text" class="form-control" id="name">
          </div>
        </div>
        <div class="form-group form-group-sm ">
          <label for="surname" class="col-sm-3">Achternaam:</label>
          <div class="col-sm-6">
            <input type="text" class="form-control" id="surname">
          </div>
        </div>
        <div class="form-group form-group-sm">
          <label for="gender" class="col-sm-3">Geslacht:</label>
          <div class="col-sm-6" id="gender">
            <label class="radio-inline"><input type="radio" name="optman">Man</label>
            <label class="radio-inline"><input type="radio" name="optwomen">Vrouw</label>
          </div>
        </div>
        <div class="form-group form-group-sm">
          <label for="dob" class="col-sm-3">Geboortedatum:</label>
          <div class="col-sm-6">
            <input type="date" format="dd/MM/yyyy" class="form-control" id="dob">
          </div>
        </div>
      </div>
    </form>
    </div>
    <div class="col-sm-2">
    <img src="http://placehold.it/200x200" class="img-profile-edit col-profile">
    </div>

    【讨论】:

    • 感谢您的回答。它不完全是我想要达到的目标。我希望图像位于输入字段的右侧,因此图像跨越表单的多行。就像this image 编辑:刚刚看到你的sn-p 全屏。我的错!在我说话的时候尝试一下。
    • 我也得到了它与你的 sn-p 的合作!非常感谢!
    【解决方案2】:

    尝试将col-sm-10 类添加到您的form

    【讨论】:

    • 我试过这个,虽然它似乎在第一个实例中工作。它弄乱了我的标签、容器的宽度和下面项目的标题。
    • 您只需要重新计算表单中的col-sm-* 类以适应新容器
    猜你喜欢
    • 1970-01-01
    • 2011-04-26
    • 1970-01-01
    • 1970-01-01
    • 2012-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多