gpt4 book ai didi

html - 你可以用css定位
吗?

转载 作者:IT老高 更新时间:2023-10-28 11:10:21 25 4
gpt4 key购买 nike

是否可以针对换行符 <br/>用 CSS 标记?

我希望每次有换行符时都有一条 1px 的虚线。我正在使用自己的 CSS 自定义网站,无法更改设置的 HTML,否则我会使用其他方式。

我不认为这是可能的,但也许有人知道。

最佳答案

从技术上讲,是的,您可以定位 <br>直接使用 CSS 元素或通过将类应用到它并定位该类。话虽这么说,一个<br>生成一个换行符,它只是一个换行符。由于此元素没有内容,因此只有少数样式可以应用在其上,例如 clear position .您可以设置<br>的边框,但您不会看到它,因为它没有视觉维度。

如果您想在视觉上将两个句子分开,那么您可能想要使用 horizontal ruler这是为了这个目标。由于您无法更改标记,因此仅使用 CSS 恐怕无法实现此目的。

看来,已经在其他论坛讨论过了。摘自 Re: Setting the height of a BR element using CSS :

[T]his leads to a somewhat odd statusfor BR in that on the one hand it isnot being treated as a normal element,but instead as an instance of \A ingenerated content, but on the otherhand it is being treated as a normalelement in that (a limited subset of)CSS properties are being allowed onit.

我还在 CSS 1 specification 中找到了说明。 (没有更高级别的规范提到它):

The current CSS1 properties and values cannot describe the behavior ofthe ‘BR’ element. In HTML, the ‘BR’element specifies a line break betweenwords. In effect, the element isreplaced by a line break. Futureversions of CSS may handle added andreplaced content, but CSS1-basedformatters must treat ‘BR’ specially.

Grant Wagner's tests显示无法设置样式BR就像你可以对其他元素一样。网上还有一个网站可以test the results in your browser .

pelms 做了一些进一步的调查,pointed out IE8(在 Win7 上)和 Chrome 2/Safari 4b 允许您设置 BR有些。事实上,我检查了IE demo pageIE Net Renderer's IE8 engine ,并且成功了。

c69 做了一些进一步的调查,结果是你 canbr 设置标记相当重(虽然,不是跨浏览器),但这不会影响换行符本身,因为它似乎属于父容器。

关于html - 你可以用css定位<br/>吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/899252/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com