Bootstrap - 正确对齐多个项目

时间:2016-05-09 22:00:48

标签: html css twitter-bootstrap

所以我在项目中使用Bootstrap面板,我的设计模型如下: enter image description here

配置文件和进度条应左对齐,而折叠图标应右对齐。

这是我目前的标记:

<div id="panelProfile" role="tab" class="panel-heading">
  <h4 class="panel-title">Profile</h4>
  <div class="progress body-profile">
    <div class="progress-bar">
      <div class="progress-filled"></div>
      <div data-bind="" class="progress-value"></div>
    </div>
  </div>
</div>

我尝试将float添加到配置文件和进度条但是这给了我: enter image description here

在不声明expicit值的情况下处理此问题的最佳方法是什么?(需要响应)

2 个答案:

答案 0 :(得分:0)

您是否尝试在div#panelProfile中使用div.row?

<div id="panelProfile" role="tab" class="panel-heading">
    <div class="row">
        <div class="col-xs-2">
            <h4 class="panel-title">Profile</h4>
        </div>
        <div class="col-xs-8">
            <div class="progress body-profile">
                <div class="progress-bar">
                    <div class="progress-filled"></div>
                    <div data-bind="" class="progress-value"></div>
                </div>
            </div>
        </div>
        <div class="col-xs-2">

        </div>
    </div>
</div>

答案 1 :(得分:0)

此代码非常适合您。
在减号图标中添加pull-right类 在个人资料中添加Pull-left课程 要使查看完整配置文件“中心”添加text-center快乐编码: - )

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Case</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<style>
 .progress{
border-radius: 15px;
  }
  .circle-minus{
    width: 5px;
    height: 3px;
    border: 1px solid black;
    border-radius: 50%;
    padding: 1px 7px;
    font-size: 14px;
  }
  .panel-heading{
    background-color: white ! important;
  }
  .panel-footer{
    background-color: white ! important;
  }
   body{
    padding-top: 15px;
  }
</style>
<body>
 
<div class="container">
  <div class="row">
  <div class="col-md-4 col-sm-6 col-xs-12">
    <div class="panel panel-default">
      <div class="panel-heading">
 <div class="pull-right"> &nbsp; &nbsp; 50% &nbsp; &nbsp; <span class="circle-minus">-</span></div>
    <div class="pull-left">Profile &nbsp; &nbsp; &nbsp; &nbsp; </div>
      <div>
    <div class="progress">

  <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="50"
  aria-valuemin="0" aria-valuemax="100" style="width:50%">
    
  </div>
</div>
      </div>


      </div>
      <div class="panel-body" style="height: 250px;"></div>
     <div class="panel-footer"><h5 class="text-center">View Complete Profile</h5></div>
   </div>
</div>
  </div>
</div>

</body>
</html>