我必须在网站上制作准响应工具栏。现在,我的html看起来像这样(它是更大文件的一部分):
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-block table-full-width">
<div class="row">
<div class="col-md-12">
<div class="toolbar">
<button class="btn btn-info float-left">loremi</button>
<button class="btn btn-primary btn-simple float-right"><i class="fas fa-info"></i></button>
<button class="btn btn-danger btn-icon float-right"><i class="fas fa-info"></i></button>
<button class="btn btn-primary float-right"><i class="fas fa-info"></i></button>
<button class="btn btn-danger float-left">loremi</button>
<button class="btn btn-danger float-left">lorem ipsum dolor s</button>
<button class="btn btn-danger float-left">lorem ipsum dolors</button>
<input type="text" class='float-right col-md-6 mr-3'>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
在全角桌面上,它看起来像我想要的(这只是引导类,我还没有添加自己的CSS代码)。当我减少浏览器时,问题开始了:
我可以使用纯flexbox来做到这一点,但是必须通过bootstrap来完成,而我才刚刚开始学习这一点。
在小设备上,我希望左侧的按钮一个位于另一个的上方(右侧的图标按钮相同)。我可以仅使用Bootstrap吗?我该如何重建HTML并添加CSS?
答案 0 :(得分:1)
我使用 col-x 类为您提供了一种方法。但是我敢肯定,有更好的方法可以做到这一点,例如使用nabvar。
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.2/css/all.css" integrity="sha384-/rXc/GQVaYpyDdyxK+ecHPVYJSN9bmVFBvjA/9eOB+pb3F2w2N6fc5qB9Ew5yIns" crossorigin="anonymous">
<div class="container-fluid">
<div class="row border border-gray">
<div id="left-section" class="col-4">
<div class="row">
<button class="col-md-3 btn btn-sm btn-info">loremi</button>
<button class="col-md-3 btn btn-sm btn-danger">loremi</button>
<button class="col-md-3 btn btn-sm btn-danger">lorem ipsum</button>
<button class="col-md-3 btn btn-sm btn-danger">lorem ipsum</button>
</div>
</div>
<div id="middle-section" class="col-6">
<input type="text" class="w-100 m-1">
</div>
<div id="right-section" class="col-2">
<div class="row">
<button class="col-md-4 btn btn-sm btn-primary">
<i class="fas fa-info"></i>
</button>
<button class="col-md-4 btn btn-sm btn-danger">
<i class="fas fa-info"></i>
</button>
<button class="col-md-4 btn btn-sm btn-primary">
<i class="fas fa-info"></i>
</button>
</div>
</div>
</div>
</div>
</div>