用空间(保留空间)更改字体大小和右键化

  • 本文关键字:空间 右键 字体 保留 php
  • 更新时间 :
  • 英文 :


我试图更改字体大小,并希望在固定位置证明文本合理。

示例更改字体大小

echo "<p style='text-align: left;'><span style='font-size: large; font-family: georgia,palatino; color: #003366;'> Test georgia,palatino Size: large </span></p> </br>";
$output = sprintf ('<p style="text-align: left;"><span style="font-size: large; font-family: georgia,palatino; color: black;"> Test georgia,palatino Size: large </span></p> </br>"');
echo $output;

str_pad

的示例
 $output = 'HTML to PHP';
 echo str_pad ( $output, 20, '*' ).'<br>';
 echo str_pad ( $output, 20, '*', STR_PAD_LEFT ).'<br>';
 echo str_pad ( $output, 20, '*', STR_PAD_BOTH ).'<br>';

示例第一个可以证明文本合理的可能性(效果很好),在第20位是下一个文本:

 echo  str_pad ( $output, 20, ' ',  STR_PAD_RIGHT ) .  str_pad ( $output, 20, ' ',  STR_PAD_RIGHT ) .'<br>' ;

示例第二可能证明文本合理性(效果很好)

 echo  sprintf("%-20s%-20s<br>" , $output, $output );

示例更改标题的字体大小(效果很好)

 $output = sprintf ('<div align="left" > <h2><span style="text-decoration: underline;"> Left: This will be underlined.</span></h2></div>' );
 echo $output;

示例更改字体大小并在固定位置处证明文本合理(不正常):

$ text ='html到php';

//确定

 echo '<pre>';
 echo  sprintf("%-20s%-20s<br>" , $text, $text );

//不正常,我不知道,如果有可能证明具有其他字体大小的文本

 $output = sprintf ('<p <span style="font-size: 10pt; font-family: georgia,palatino; color: black;"> %s </span></p>', $text);
 echo str_pad ( $output, 20, '*', STR_PAD_RIGHT ) . str_pad ( $output, 20, '*', STR_PAD_RIGHT ) ;
 echo  sprintf("%-20s%-20s<br>" , $output, $output );

您刚刚在p标签中写了 span标签。您必须启动<p>。您没有编写>并在<p <span中启动span,这是无效的。

我将其修复并再次进行测试,但是我无法在定义的位置上证明文本是合理的:

 $text = 'HTML to PHP';
 echo '<pre>';
 echo  sprintf("Test 1: %-20s%-20s<br>" , $text, $text );
 $output = sprintf ('<p> <span style="font-size: 10pt; font-family: georgia,palatino; color: black;"> %s </span></p>', $text);

// This works ok 
 echo $output;
 // This test produces a output in two lines !!!
 echo str_pad ( $output, 20, ' ', STR_PAD_RIGHT ) . str_pad ( $output, 20, ' ', STR_PAD_RIGHT ) ;
 // This test produces also a output in two lines !!!
 echo  sprintf("%-20s%-20s<br>" , $output, $output );

最新更新