Bootstrap列未内联显示 [英] Bootstrap columns not appearing inline

查看:81
本文介绍了Bootstrap列未内联显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一般来说,我是Bootstrap和CSS的新手。我有一些看起来像这样的html:

I'm new to bootstrap and CSS in general. I have some html which looks like this:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My Site</title>
    <link rel="stylesheet" href="/css/bootstrap-theme.css">
    <link rel="stylesheet" href="/css/font-awesome.css">
  </head>
  <body>
    <div class="container">
      <div class="row">
        <div class="col-md-1"><span class="fa fa-caret-down"></span></div>
        <div class="col-md-1"><span id="cool-title">My Site</span></div>
        <div class="col-md-1">
          <input type="text" placeholder="Search" class="search-bar">
        </div>
        <div class="col-md-1">
          <button class="btn btn-default"><i class="fa fa-search col-md-1"></i></button>
        </div>
      </div>
      <div id="main">
      </div>
    </div>
    <script src="/js/jquery.js"></script>
    <script src="/js/bootstrap.js"></script>
  </body>
</html>

我希望所有这些 col- divs内联,但它们都显示在自己的行上:

I want all of those col- divs to be inlined, but they are all showing up on their own rows:

这是怎么回事?

推荐答案

您正在使用 /css/bootstrap-theme.css 。请使用 /css/bootstrap.css /css/bootstrap.min.css 。 bootstrap-theme.css没有 col-属性。

You are using /css/bootstrap-theme.css. Use /css/bootstrap.css or /css/bootstrap.min.css instead. bootstrap-theme.css doesn't have "col- " properties.

此外,而不是仅使用一个 class = col-md- 1 (对于中等大小的视口/屏幕),您可能希望使用类似 class = col-xs-12 col-sm-6 col-md-3 col- lg-3 可使您的列响应不同的屏幕。 ( xs代表超小屏幕, lg代表大屏幕,等等。使用这些数字。Bootstrap使用12列网格布局,因此使用12的系数作为数字。)

Also, instead of using just one class="col-md-1" (for medium sized viewport/screen) you might want to use something like class="col-xs-12 col-sm-6 col-md-3 col-lg-3" that makes your columns responsive to different screens. ('xs' for extra small screen, 'lg' for large screen etc. Play around with these numbers. Bootstrap uses a 12 columns grid layout, so use factors of 12 as the numbers.)

这篇关于Bootstrap列未内联显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆