html - 将DIV放置在窗体的右侧

标签 html css

我在表单中有一个 div,我想将 div 放在表单的右侧,并且 div 必须用按钮固定在右侧。我不知道这是否可以完成,但我该如何完成。

HTML

<form class="form-horizontal" method="post">
   <div class="form-group">
      <label for="name" class="col-lg-1 control-label"> Name</label>
      <div class="col-lg-6">
         <input type="text" class="typeahead form-control" id="name" placeholder="Name" name="name" required>
      </div>
   </div>
   <!--i want to move this div to the right side of the form and fixed-->
   <div  style="background-color:white" class="move-right" id="move-right">
      <legend style="text-align: center" >Heading <span></span></legend>
   </div>
   <div>
      <button type="submit" class="btn ">Save</button>
   </div>
</form>
</div>

最佳答案

如果权利的内容应该不重叠您需要的其他内容:

.move-right { float :右; 在 css 中。 并重新排序 html 代码以将 float 元素放在其他元素之上:

    <form class="form-horizontal" method="post">
       <div  style="background-color:white" class="move-right" id="move-
right">
          <legend style="text-align: center" >Heading <span></span></le zgend>
       </div>
       <div class="form-group">
          <label for="name" class="col-lg-1 control-label"> Name</label>
          <div class="col-lg-6">
             <input type="text" class="typeahead form-control" id="name" 
placeholder="Name" name="name" required>
          </div>
       </div>
       <div>
          <button type="submit" class="btn ">Save</button>
       </div>
    </form>

否则,如果内容可以重叠:

使用 .move-right { position: absolute;右:0px; .form-horizo​​ntal { position: relative; CSS 代码。

关于html - 将DIV放置在窗体的右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47323784/

相关文章:

jQuery 悬停在一个 div 上触发另一个 div 的变化

网站的 HTML 布局无法正确显示

javascript - 根据 LESS/Javascript 中的条件对常见的 css 规则进行分组?

HTML/CSS 模式对话框 : Centering Content of Unknown Size -- Scrolling on Overflow

php - 无法使搜索栏响应

php - 根据变量创建多个div

javascript - 如何打开一个弹出文本框要求用户提交评论?

javascript - JQuery show element 其中有一个元素的类在

html - Css 类不能在跨度内工作

css - 如何向 HTML5 表格添加滚动条?