我正在學習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>
在上文中,
<div id="text">span5 text</div>
水平開始恰好第四列的開始。我想知道引導專家用戶如何使用CSS來定位
<div id="text">span5 text</div>
,使之成爲第三和第四列之間開始或者第八和第九列之間結束。
我正在考慮使用兩種:
<style>
#text {
margin-left:-10px;
}
</style>
或
<style>
#text {
position:relative;
left:-10px;
}
</style>
來定位DIV,但不知道是否這是首選,想知道專家做什麼,一些其他的方法。
謝謝!
你我一個從列之間的「邊緣」的中間? – albertedevigo
是的。我想將該div定位到任何位置。 – curious1