清除(HTML属性)

tech2023-01-10  123

描述 (Description)

The clear attribute is a deprecated (presentational) attribute that’s used to clear any preexisting right or left alignments. It ensures that the content after the br element appears beneath the baseline of the previously aligned element; the br doesn’t just create a line break in the content that’s flowing around the right- or left-aligned element.

clear属性是不推荐使用的(表示性)属性,用于清除任何先前存在的右对齐或左对齐。 它确保br元素之后的内容出现在先前对齐的元素的基线之下; br不仅会在围绕右对齐或左对齐元素的内容中创建换行符。

In the past, this approach would most often have been used to stop content wrapping around a right- or left-aligned image or table.

过去,这种方法最常用于停止围绕右或左对齐的图像或表格进行内容环绕。

The correct way of managing alignment issues is to use the CSS float property, rather than the HTML align attribute. To clear elements, we use the CSS clear property like so:

解决对齐问题的正确方法是使用CSS float属性,而不是HTML align属性。 为了清除元素,我们使用CSS clear属性,如下所示:

<br clear="left"/> the old-fashioned HTML way <br style="clear:left;"/> the CSS way

Note that you should avoid inline CSS styles—the inline style above is provided for direct comparison purposes only.

请注意,您应该避免使用内联CSS样式-上面的内联样式仅用于直接比较。

(Example)

This example shows a br with which a clear attribute is used to take content below a right-aligned image:

此示例显示了一个br ,使用br时, clear属性用于获取右对齐图像下方的内容:

<p><img src="pool.jpg" alt="sitting by the pool" align="right"/> The rest of the day was a lazy one, partly spent by the complex pool, partly inside watching British TV, but we couldn't be doing this for the rest of the holiday. Already we were missing having the car! <br clear="all"/> I decided to check out what the weather would be doing for the next few days, as that would help us make any decisions about future excursions. </p>

翻译自: https://www.sitepoint.com/clear-html-attribute/

最新回复(0)