Bootstrap:如何在网格设计中的任何位置水平放置元素?

cur*_*us1 5 twitter-bootstrap

我正在学习Bootstrap.我使用Bootstrap进行固定宽度的设计.从在线文档中,我知道从列开始定位元素很容易.例如:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Bootstrap version</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding-top: 60px;
            padding-bottom: 40px;
        }
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">

    <link href="learn.css" rel="stylesheet">

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

</head>

<body>


<div class="container">
    <div class="row">
    <div class="span3" style="background-color:grey">span3</div>
    <div class="span5" style="background-color:pink"><div id="text">span5 text</div></div>
    <div class="span4" style="background-color:navy">span4</div>
    </div>
</div> 


    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="js/jquery-1.9.1.min.js"><\/script>')</script>    
    <script src="js/bootstrap.min.js"></script> 
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在上面,

<div id="text">span5 text</div>
Run Code Online (Sandbox Code Playgroud)

水平开始正好在第四列开始的位置.我想知道Bootstrap专家用户如何使用CSS定位

<div id="text">span5 text</div>
Run Code Online (Sandbox Code Playgroud)

使其在第三和第四列之间开始或在第八和第九列之间结束.

我在考虑使用以下两种方法:

<style>
#text {
margin-left:-10px;
}
</style>
Run Code Online (Sandbox Code Playgroud)

要么

<style>
#text {
    position:relative;
    left:-10px;
}
</style>
Run Code Online (Sandbox Code Playgroud)

定位div,但不确定哪个是首选,想知道专家做了什么以及其他一些方法.

谢谢!

Zim*_*Zim 4

默认情况下,Bootstrap 跨度之间始终有一个左边距(或装订线)(请参见此处: http: //bootply.com/64463)。如果您想覆盖它,可以使用 CSS,但是您将失去 Bootstrap 的响应式优势,因为该元素将从正常页面流中删除。

更好的选择可能是没有装订线的自定义 Bootstrap 构建:http://twitter.github.io/bootstrap/customize.html#variables

或者,您可以创建一个自定义 CSS 类,根据需要应用于行,就像这个无装订线示例: http: //bootply.com/61712