首页 > 解决方案 > 如何删除 HTML/CSS 中两个 div 之间的空格?

问题描述

我有一个简单的 HTML/CSS 代码来获得粉色带和黑色较小的带,没有空格。这是我的 CSS 和 HTML 代码问题是我在两次潜水之间有空格,我从网上尝试了许多解决方案,但没有结果。

请问有什么帮助吗?

.my_bande_rose    {  background-color: #E6007E; 
                     height: 124px; 
                     width:  100%; 
                     margin-top: 0;
                     margin-bottom: 0;
                     padding-top: 0;
                     padding-bottom: 0;                     
                  }
.bande_horizontale{  float: right;
                     width: 83.4%; 
                     height: 5px; 
                     background-color: #000000; 
                     margin-top: 0;
                     margin-bottom: 0;
                     padding-top: 0;
                     padding-bottom: 0;                     
                  } 
 .my_logo         {  height: 124px;
                     width:225px;
                     top: 0px;
                     float:left;
                  }
 .my_title        {  width:260px;
                     float:right;
                     margin:25px auto;
                     font-weight:bold;
                     padding:5px;
                  }
<html>
<head>
<script type="text/javascript" 
           src="../js/mathjax/MathJax.js?config=AM_HTMLorMML-full">
</script>
</head>
<body>
<div>
<div class="my_bande_rose">
<div class="my_title">
<h5 style="color:#ffffff;" >My tittle</h5>
</div><div class="my_logo">
<img src="https://www.pajemploi.urssaf.fr/pajewebdeclaratif/images/pajeweb/newletter/logo_forme.jpg" alt="Pajemploi, un service des urssaf"/>
</div><div class="bande_horizontale"></div>
</div> <br>
<h2 style="color:#E6007E;" >My tittle again</h2>
</div>
</body>

</html>

标签: htmlcss

解决方案


如果您引用黑色 div 左侧的空间,则需要更改以下.bande_horizontale属性:

float: left;
width: 100%;

推荐阅读