html - 如何让 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>
解决方案
推荐阅读
- c++ - 在输入向量的笛卡尔积中创建第 n 个元素的元组
- html - h3 和锚定内联块(在同一行)
- python - TKinter 处理多显示器和图像显示
- python - 对于 Python 中另一个列表的每个不同值,计算一个列表的最大值和最小值的最佳方法是什么?
- javascript - React .map 不重新渲染
- sql-server - 没有 Azure 订阅,无法创建集成服务目录
- c++ - 将整数分配给 char * 指针数组中的索引
- python-3.x - 更新条目小部件实时 tkinter
- android - 使用 Firebase 时无法计算儿童数量
- android - 以编程方式将 MenuItem 添加到 Group 不会添加单选按钮