用 boostrap 布局,左边内容,右边是侧边栏,奇怪问题。

2016-07-07 13:18:28 +08:00
 CareiOS

分左右两个面板,左边是内容面板,右边是侧边栏面板。 右边侧边栏面板高度会影响左边 form 表单的上下间距。我是 html5 新手,可能这问题很简单,可是我没法解决,只能求助 V 友。

html 源码:

<!DOCTYPE html>
<html>
<head>
   <title>布局实例</title>
   <link rel="stylesheet" href="css/bootstrap.css" media="all">
   <script type="text/javascript" src="js/jquery-3.0.0.min.js"></script>
   <script type="text/javascript" src="js/bootstrap.js"></script>
   <meta charset="utf-8"/>
</head>
<body>

   <!-- sider -->
   <div id="sider" style="width:400px; margin-bottom:-3000px; padding-bottom:3000px; background:#f0f3f9; float:right;">
      <div class="panel panel-default">
         <div class="panel-heading">
            <h3 class="panel-title">带有 title 的面板标题</h3>
         </div>
         <div class="panel-body">面板内容</div>
         <div class="panel-body">面板内容</div>
         <div class="panel-body">面板内容</div>
         <div class="panel-body">面板内容</div>
      </div>
   </div>

   <!-- content -->
   <div id="center" style="margin:0 410px 0 210px; background:#ffe6b8; height:600px;">
      <div class="panel panel-default">
         <div class="panel-heading">
            <h3 class="panel-title">
               带有 title 的面板标题
            </h3>
         </div>
         <div class="panel-body">
            <form id='change_pass_form' class='form-horizontal' action='/setting' method='post'>
               <div class='form-group'>
                  <label class='control-label col-md-2' for='old_pass'>当前密码</label>

                  <div class='col-md-6'>
                     <input class='form-control' type='password' id='old_pass' name='old_pass' size='30'/>
                  </div>
               </div>

               <div class='form-group'>
                  <label class='control-label col-md-2' for='old_pass'>当前密码</label>

                  <div class='col-md-6'>
                     <input class='form-control' type='password' id='old_pass' name='old_pass' size='30'/>
                  </div>
               </div>
            </form>
         </div>
   </div>
</body>
</html>

4037 次点击
所在节点    HTML
1 条回复
notgod
2016-07-07 13:20:26 +08:00
用 row 定位布局
或者 div clear 一次
看下官方文档和演示

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/290852

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX