我正在使用bootstrap构建静态电子商务网站。我想要在手机中打开时连续2个产品,在桌面或i-pad中打开时连续4个产品。
<div class="container">
<div class="row product">
<div class="col-md-3">
<div class="image">
<a href="products.php?q=10020" target="_blank"><img id="10030" src="#"></a>
</div>
</div>
<div class="col-md-3">
<div class="image">
<a href="products.php?q=10020" target="_blank"><img id="10030" src="#"></a>
</div>
</div>
<div class="col-md-3">
<div class="image">
<a href="products.php?q=10020" target="_blank"><img id="10030" src="#"></a>
</div>
</div>
<div class="col-md-3">
<div class="image">
<a href="products.php?q=10020" target="_blank"><img id="10030" src="#"></a>
</div>
</div>
</div>
此页面上有超过1行。 请帮我解决这个问题。
答案 0 :(得分:0)
您遇到的问题是因为您的引导网格。
我在下面做了一个例子。注意:class =&#34; col-xs-6 col-md-3&#34;
以下是文档。 https://www.w3schools.com/bootstrap/bootstrap_grid_basic.asp
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-xs-6 col-md-3" style="background-color:green;">1</div>
<div class="col-xs-6 col-md-3" style="background-color:blue;">2</div>
<div class="col-xs-6 col-md-3" style="background-color:red;">3</div>
<div class="col-xs-6 col-md-3" style="background-color:yellow;">4</div>
</div>
</div>
</body>
</html>