摆脱多余的空间

时间:2019-10-22 08:25:06

标签: html css

在php文件中有以下代码:从代码的第一行定义标题(屏幕截图的第一行),第二个城市定义城市,第三和第四个定义城市旁边的“ price_new”或“ price”(如果存在)(屏幕截图),五个和六个定义了price_two和min_amount(屏幕截图的第三行),最后一个是类别(屏幕截图的第四行):

问题是我无法摆脱屏幕快照第二行和第三行之间的多余空间:

<a class="b" title="<?=$last['title']?>" href="<?="c".$last['id_category']."-".$last['board_id']?>.html"><?=$last['title']?></a><br /><span>

      <? if(defined('JBLANG')&& constant('JBLANG')=='en') echo $last['en_city_name']; else echo $last['city_name'];
         if(($last['price'] > $last['price_new']) && ($last['price_new'] != 0)) echo " | <s class=\"red\">".$last['price']." ".$last['prise']."</s>.";
         if($last['price'] != 0 && $last['price_new'] == 0) echo " | <span class=\"green\">".$last['price']." ".$last['prise']."</span>";  
         if ($last["price_two"]) echo '</span><br /><a style="display: inline-block;" class="sm_11"><span>Цена Оптом</span> <span class="green">'.$last["price_two"].' '.$last["price_two_currency"].'<span></a>';
         if ($last["min_amount"]) echo ' | <a style="display: inline-block;" class="sm_11" style="margin-left: 22%;"><span>Мин. кол-во</span> <span class="green">'.$last["min_amount"].' '.$last["min_amount_currency"].'<span></a>' ?>

         </span>
         <br /><a style="display: inline-block;" class="sm_11" title="<?=$last[$name_cat]?>" href="<?="c".$last['id_category']?>.html"><?=$last[$name_cat]?></a>

谢谢, S

enter image description here

1 个答案:

答案 0 :(得分:0)

只需将一个类添加到您使用的div / html标记中。这是一个示例:

.example_class{
  line-height:1px;
}

.large_example_class{
  line-height:300px;
}
<div class="example_class">
   <p> Hello </p>
   <p> World </p>
</div>

<div class="large_example_class">
  <p>Hello</p>
  <p>World</p>
</div>

但是,行高确实会影响div中文本行上方和下方的空格。如果您想单独进行操作,则需要这样做:

.line_1{
  margin: 0px;
}

.line_2{
  margin-top:10px;
}

.line_3{
  margin-top:200px;
}
<div>
  <p class="line_1">Hello</p>
  <p class="line_2">World</p>
  <p class="line_3">Hello</p>
</div>

基本上,在此处将页边距设置在顶部,这仅影响给定的行。但是,如果您将此类与其他itme一起重用,则它们将以相同的方式受到影响。

在您的示例中,我将使用以下内容:

<?php 
  echo'</span><p><a style="display:block; background-color:white;">Hello</a></p>'

但是,您应该使用一个类来更改样式属性,以使其更具通用性。如果您想进一步了解此代码,请访问W3 Schoolstutorialspoint

这样的网站