您可以指定< br />与css? [英] Can you target <br /> with css?

查看:98
本文介绍了您可以指定< br />与css?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道是否有人知道是否可以使用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.

似乎已经在其他论坛上讨论过了。从 Re:使用CSS设置BR元素的高度提取

It seems, it has been already discussed on other forums. Extract from Re: Setting the height of a BR element using CSS:


[T]他导致一个有点奇怪的状态
BR的一方面是
不被视为正常元素
,而是作为
中生成的内容中的\A的实例,但在另一个
手中,它被视为正常的
元素

[T]his leads to a somewhat odd status for BR in that on the one hand it is not being treated as a normal element, but instead as an instance of \A in generated content, but on the other hand it is being treated as a normal element in that (a limited subset of) CSS properties are being allowed on it.

我也发现了一个澄清在 CSS 1规范(没有更高的级别规范):

I also found a clarification in the CSS 1 specification (no higher level spec mentions it):


当前的CSS1属性和值不能描述
'BR'元素的行为。在HTML中,'BR'
元素指定
个字之间的换行符。实际上,元素是换行符
。未来
版本的CSS可能处理添加的内容,
替换内容,但基于CSS1的
格式化程序必须特别处理BR。

The current CSS1 properties and values cannot describe the behavior of the ‘BR’ element. In HTML, the ‘BR’ element specifies a line break between words. In effect, the element is replaced by a line break. Future versions of CSS may handle added and replaced content, but CSS1-based formatters must treat ‘BR’ specially.

Grant Wagner的测试显示没有办法像你可以做的其他元素样式 BR 。还有一个在线网站,您可以在浏览器中测试结果

Grant Wagner's tests show that there is no way to style BR as you can do with other elements. There is also a site online where you can test the results in your browser.

更新

pelms进行了进一步调查,指出 IE8(在Win7上)和Chrome 2 / Safari 4b允许你要稍微风格 BR 。事实上,我查看了 IE演示页 IE Net Renderer的IE8引擎,它工作正常。

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 2 c69 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆