如何使两个div彼此相邻

时间:2017-03-31 13:08:16

标签: html css html5 css3

不幸的是,我不知道如何使这些div(盒子)像照片一样彼此相邻,并把像汽车的图像放在图像中,任何人都可以帮助我

如果有表格或div的方式,请帮助我这样做

here is the image

3 个答案:

答案 0 :(得分:1)



.block1{
  background: red;
  height: 150px;
  padding-top: 30%;
}

.block2{
  background: green;
  height: 150px;
  padding-top: 30%;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


<div class="col-xs-12 text-center">
<div class="col-xs-6">
<div class="block1">
  text
</div>
</div>


<div class="col-xs-6">
<div class="block2">
  text
</div>
</div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

你可以使用float:left为父div中的2个div

答案 2 :(得分:0)

试试这个html + bootstrap可以正常用于移动视图:

<!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.2.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>


<div class="container">
  <div class="row">
    <div class="col-sm-4">
     Image 1
    </div>
    <div class="col-sm-4">
      Image 2
    </div>
    <div class="col-sm-4">
      Image 3
    </div>
  </div>
</div>

</body>
</html>