简体   繁体   English

摆脱多余的空间

[英]Get rid of extra space

Have following codes in php file: from code the first line defines title (first line from screenshot), second one city, third and fourth ones defines 'price_new' or 'price' next to the city if exists (second line from screenshot), five and six ones define price_two and min_amount (third line from screenshot) and the last one is category (fourth line from screenshot):在 php 文件中有以下代码:从代码的第一行定义标题(屏幕截图的第一行),第二个城市,第三和第四个定义城市旁边的“price_new”或“价格”(如果存在)(屏幕截图的第二行),五个和六个定义了 price_two 和 min_amount(屏幕截图的第三行),最后一个是类别(屏幕截图的第四行):

The problem is I can't get rid off extra space between second and third lines from screenshot:问题是我无法摆脱屏幕截图中第二行和第三行之间的额外空间:

<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>

Thanks, S谢谢,

在此处输入图像描述

Simply add a class to the div/html tag you're using.只需将 class 添加到您正在使用的 div/html 标记。 Here's an example:这是一个例子:

 .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>

Line height does however affect the whitespace both above and under the text lines in the div.然而,行高确实会影响 div 中文本行上方和下方的空白。 If you want to do it individually you need to do it like this:如果你想单独做,你需要这样做:

 .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>

Basically here you set the margin on the top, which only affects the given line.基本上在这里你设置顶部的边距,它只影响给定的行。 If you however reuse this class with other itme they'll be affected in the same way.但是,如果您将此 class 与其他项目一起使用,它们将以同样的方式受到影响。

In your example I'd use the following:在您的示例中,我将使用以下内容:

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

However, you should change your style attribute with a class to make it more universal.但是,您应该使用 class 更改样式属性以使其更通用。 If you wish to know more about this code look at websites like W3 Schools or tutorialspoint如果您想了解有关此代码的更多信息,请查看W3 Schoolstutorialspoint等网站

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM