你好,我目前正在努力弄清楚如何使两个类同时浮动,同时使用Bootstrap,我想要完成的是让我的文本向左浮动,图像浮动到右边!这是我的代码:
<div class="row-fluid">
<div id="test-1" class="span6"></div>
<div id="test-2" class="span6"></div>
</div>
body {
background-color: black;
}
#test-1 {
background-color: white;
height: 200px;
width: 200px;
}
#test-2 {
background-image: url("http://www.rd.com/wp-content/uploads/sites/2/2016/04/01-cat-wants-to-tell-you-laptop.jpg");
background-size: cover;
background-repeat: no-repeat;
height: 200px;
width: 200px;
}发布于 2017-02-06 18:57:10
您可以同时使用pull-left & pull-right或col-xs-6,这取决于您到底想达到什么目的。
下面的代码后面跟着jsfiddle链接,显示了所做的两件事:
body {
background-color: black;
}
#test-1 {
background-color: white;
height: 200px;
width: 200px;
}
#test-2 {
background-image: url("http://www.rd.com/wp-content/uploads/sites/2/2016/04/01-cat-wants-to-tell-you-laptop.jpg");
background-size: cover;
background-repeat: no-repeat;
height: 200px;
width: 200px;
}<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="row-fluid">
<div id="test-1" class="span6 pull-left"></div>
<div id="test-2" class="span6 pull-right"></div>
</div>
<div class="clearfix"></div>
<div class="row-fluid">
<div id="test-1" class="span6 col-xs-6"></div>
<div id="test-2" class="span6 col-xs-6"></div>
</div>
Jsfiddle链接:https://jsfiddle.net/jLfcpssz/
发布于 2017-02-06 18:51:32
引导程序有一个名为拉右拉左的类,我认为它们可能对您有用。
body {
background-color: black!important;
}
#test-1 {
background-color: white;
height: 200px;
width: 200px;
}
#test-2 {
background-image: url("http://www.rd.com/wp-content/uploads/sites/2/2016/04/01-cat-wants-to-tell-you-laptop.jpg");
background-size: cover;
background-repeat: no-repeat;
height: 200px;
width: 200px;
}<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="container">
<div class="row">
<div id="test-1" class="col-md-6 span6 pull-left"></div>
<div id="test-2" class="col-md-6 span6 pull-right"></div>
</div>
</div>
https://stackoverflow.com/questions/42074944
复制相似问题