Bootstrap span 类无法按预期工作 [英] Bootstrap span classes not working as expected

查看:19
本文介绍了Bootstrap span 类无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了我的第一个引导程序.

<头><link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="样式表"><身体><div class="row">

列的第 1 级

<div class="row"><div class="span6">Level 2</div><div class="span3">Level 2</div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script></html>

我希望 div class 9 只占用 9 列而不是整个浏览器宽度.我希望 span6 和 span3 将占据 6 和 3 列并在同一行中.

但输出看起来像

因此行显示不正确(它们被剪切)并且行和列也没有得到尊重.(在 chrome 中,我可以看到级别 1 占用了整个浏览器宽度)2 span6 和 span3 类也是如此.它们占据了整个浏览器宽度.

解决方案

您在标题中引用了 bootstrap 3.1.1 css 文件,但是您在其中使用了 bootstrap 2 css 类(例如 span3)您的 html 代码.

使用 bootstrap 3 类代替,如下所述:http://getbootstrap.com/css/

例如使用 col-lg-3 而不是 span3.

试试这个:

<代码>...<div class="row"><div class="col-lg-9">列的级别 1</div>

<div class="row"><div class="col-lg-6">Level 2</div><div class="col-lg-3">Level 2</div>

...

I wrote my first bootstrap program.

<!DOCTYPE html>
<html>
    <head>
        <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>
        <div class="row">
            <div class="span9">Level 1 of Column</div>
        </div>
        <div class="row">
            <div class="span6">Level 2</div>
            <div class="span3">Level 2</div>
        </div>

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
        <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
    </body>    
</html>

My hope was that the div class 9 will only take up 9 columns instead of entire browser width. My hope was that span6 and span3 will take up 6 and 3 columns and will be in the same row.

But the output looks like

So the rows do not appear properly (they are being cut) and also the rows and columns are not being respected. (in chrome I can see that level 1 is taking up the entire browser width) so is the 2 span6 and span3 classes. they take up entire browser width.

解决方案

You refer to bootstrap 3.1.1 css file in your header, but you are using bootstrap 2 css classes (e.g. span3) within your html code.

Use bootstrap 3 classes instead as described here: http://getbootstrap.com/css/

So for example use col-lg-3 instead of span3.

Try this:

...
<div class="row">
    <div class="col-lg-9">Level 1 of Column</div>
</div>
<div class="row">
    <div class="col-lg-6">Level 2</div>
    <div class="col-lg-3">Level 2</div>
</div>
...

这篇关于Bootstrap span 类无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆