问题描述
想知道是否有人知道是否可以使用css来定位换行符。基本上所有我想做的是有一个1px虚线每次有一个换行符。我自定义一个网站与我自己的css,不能改变集合html,否则我会使用一些其他的方式。我不认为这是可能的,但也许有一种方式有人知道。 - 谢谢!
wondering if anyone knows if it is possible to target line-break tag with css. Basically all I want to do is have a 1px dashed line every-time there is a line-break. I am customising a site with my own css and cannot change the set html, otherwise I would use some other way. I don't think it is possible but maybe there is a way someone knows about. - Thanks!
推荐答案
BR
生成换行符, -打破。由于此元素没有内容,因此只有很少的样式可以应用,例如或位置
。您可以设置 BR
的边框,但是您不会看到它,因为它没有视觉尺寸。
BR
generates a line-break and it is only a line-break. As this element has no content, there are only few styles that make sense to apply on it, like clear
or position
. You can set BR
's border but you won't see it as it has no visual dimension.
您喜欢视觉上分隔两个句子,那么您可能想使用为此目标。由于您无法更改标记,因此恐怕仅使用CSS无法实现此功能。
If you like to visually separate two sentences, then you probably want to use the horizontal ruler which is intended for this goal. Since you cannot change the markup, I'm afraid using only CSS you cannot achieve this.
似乎已经在其他论坛上讨论过了。从 提取:
It seems, it has been already discussed on other forums. Extract from Re: Setting the height of a BR element using CSS:
我也发现了一个澄清在(没有更高的级别规范):
I also found a clarification in the CSS 1 specification (no higher level spec mentions it):
显示没有办法像你可以做的其他元素样式 BR
。还有一个在线网站,您可以在浏览器中 IE8(在Win7上)和Chrome 2 / Safari 4b允许你要稍微风格 BR
。事实上,我查看了 ,它工作正常。
pelms made some further investigations, and pointed out that IE8 (on Win7) and Chrome 2/Safari 4b allows you to style BR
somewhat. And indeed, I checked the IE demo page with IE Net Renderer's IE8 engine, and it worked.
更新2
c69进行了进一步调查,结果表明您可以对 br
相当大地(虽然,不是跨浏览器)对标记 break自己,因为它似乎属于父容器。
Update 2c69 made some further investigations, and it turns out you can style the marker for br
quite heavily (though, not cross-browser), yet this will not affect the line-break itself, because it seem to belong to parent container.
这篇关于您可以指定< br />与css?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!