107 lines
6.4 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<article id="wikiArticle">
<div> <div class="blockIndicator deprecated deprecatedHeader">
<p><strong><span class="icon-only-inline" title="This is an obsolete API and is no longer guaranteed to work."><i class="icon-trash"> </i></span> 已废弃</strong><br/>该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。</p>
</div></div>
<p><strong><code>small()</code></strong> 方法的作用是创建一个使字符串显示小号字体的 <a href="/zh-CN/docs/Web/HTML/Element/small" title="HTML 中的元素將使文本的字体变小一号。(例如从大变成中等,从中等变成小,从小变成超小)。在HTML5中除了它的样式含义这个元素被重新定义为表示边注释和附属细则包括版权和法律文本。"><code>&lt;small&gt;</code></a> 标签。</p>
<h2 id="语法">语法</h2>
<pre><code class="language-javascript"><code><var>str</var>.small()</code></code></pre>
<h3 id="返回值">返回值</h3>
<p>带有 <a href="/zh-CN/docs/Web/HTML/Element/small" title="HTML 中的元素將使文本的字体变小一号。(例如从大变成中等,从中等变成小,从小变成超小)。在HTML5中除了它的样式含义这个元素被重新定义为表示边注释和附属细则包括版权和法律文本。"><code>&lt;small&gt;</code></a> 标签的字符串。</p>
<h2 id="描述">描述</h2>
<p><code>small()</code> 方法会 将一个字符串嵌入到<code>&lt;small&gt;</code> 标签中: <code>"&lt;small&gt;str&lt;/small&gt;"。</code></p>
<h2 id="示例">示例</h2>
<h3 id="使用small()函数"><code>使用small()函数</code></h3>
<p>为了改变一个字符串的字体大小,下面的例子使用了字符串中的方法:</p>
<pre><code class="language-javascript">var worldString = 'Hello, world';
console.log(worldString.small()); // &lt;small&gt;Hello, world&lt;/small&gt;
console.log(worldString.big()); // &lt;big&gt;Hello, world&lt;/big&gt;
console.log(worldString.fontsize(7)); // &lt;font size="7"&gt;Hello, world&lt;/fontsize&gt;
</code></pre>
<p>使用<a href="/zh-CN/docs/Web/API/HTMLElement/style" title="HTMLElement.style 属性返回一个 CSSStyleDeclaration 对象表示元素的 内联style 属性attribute但忽略任何样式表应用的属性。 通过 style 可以访问的 CSS 属性列表可以查看 CSS Properties Reference。"><code>element.style</code></a>对象,你能更加一般地获得和操作该元素的属性,比如:</p>
<pre><code class="language-javascript">document.getElementById('yourElemId').style.fontSize = '0.7em';
</code></pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-string.prototype.small" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">String.prototype.small</small></a></td>
<td><span class="spec-Standard">Standard</span></td>
<td>初始定义。 在JavaScript 1.0中实现。在规范性附件B中定义了用于Web浏览器的附加ECMAScript 特性。</td>
</tr>
<tr>
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-string.prototype.small" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">String.prototype.small</small></a></td>
<td><span class="spec-Draft">Draft</span></td>
<td>规范性附件B中定义了用于Web浏览器的附加ECMAScript 特性。</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<div><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
<div class="htab">
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
<ul>
<li class="selected"><a>Desktop</a></li>
<li><a>Mobile</a></li>
</ul>
</div></div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td>1.0 (1.7 or earlier)</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Chrome for Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td>1.0 (1.0)</td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
</tr>
</tbody>
</table>
</div>
<h2 id="相关链接">相关链接</h2>
<ul>
<li><a href="Reference/Global_Objects/String/fontsize" title="The fontsize() method creates a &lt;font&gt; HTML element that causes a string to be displayed in the specified font size."><code>String.prototype.fontsize()</code></a></li>
<li><a href="Reference/Global_Objects/String/big" title="big()方法的作用是创建一个使字符串显示大号字体的&lt;big&gt;标签。"><code>String.prototype.big()</code></a></li>
</ul>
</article>