我正在使用Bootstrap。当屏幕重新调整大小为sm/xs
时,我想更改默认的div位置(默认位置是紫色div超过红色,当你的屏幕/窗口变小时)。基本上我想得到下图所示的内容。
我尝试使用push
和pull
更改位置,但它不起作用。
由于
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="Keywords" content="">
<meta name="robots" content="index,follow">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div style="background-color:#8000ff; height:200px" class="col-md-8 col-sm-12">Example1</div>
<div style="background-color:red; height:200px" class="col-md-4 col-sm-12">Example2</div>
</div>
</div>
</body>
</html>
&#13;
答案 0 :(得分:2)
您可以使用.col-md-push-*
和.col-md-pull-*
修饰符类轻松更改网格列的顺序。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="Keywords" content="">
<meta name="robots" content="index,follow">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div style="background-color:red; height:200px" class="col-sm-12 col-md-4 col-md-push-8">Example2</div>
<div style="background-color:#8000ff; height:200px" class="col-sm-12 col-md-8 col-md-pull-4 ">Example1</div>
</div>
</div>
</body>
</html>
&#13;