简体   繁体   中英

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

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

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. If you wish to know more about this code look at websites like W3 Schools or tutorialspoint

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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