首页 > 解决方案 > 如何让 2 个 div 彼此相邻

问题描述

问题是当我尝试使用display:inline属性时,第一个 div 的底部现在是第二个 div 的顶部,有什么办法可以解决这个问题。我尝试添加边距,但这无济于事

div#test1 {
  font-family: 'Montserrat', sans-serif;
  height: 300px;
  width: 300px;
  margin-left: 30px;
  font-size: 20px;
  text-align: left;
}

p#test2 {
  font-size: 40px;
  margin-bottom: 15px;
}

a#View_more1 {
  text-decoration: none;
  padding: 10px 20px;
  font-family: sans-serif;
  background-color: black;
  color: white;
}

i {
  padding-bottom: 1000px;
  background-color: gray;
  border-radius: 50%;
  border: 1px solid grey;
  padding: 10px;
}

div#div02 {
  height: 300px;
  width: 300px;
  background-color: green;
  margin-bottom: 500px;
}
<div>
  <div id="test1" style="display:inline-block">
    <p id="test2">fdhsbfs</p>
    <p>bhdusfsbhjhfjh h gsdbh bbs dhgfshfusdgsv</p><br>
    <a href="#" id="View_more1">View More</a>
  </div>
  <div id="div02" style="display:inline-block">
    <i class="fas fa-desktop"></i>
  </div>

标签: htmlcss

解决方案


推荐阅读