CSS:删除线未在文本中居中
我们使用删除线来实际显示产品的旧价格与新价格。
如果您打开此链接,在页面底部,我们有一款产品正在促销。 http://www.gkelite.com/Gymnastics-Shopby-GiftoftheWeek
删除线因为旧的价格没有垂直居中。 任何人都可以帮忙解释为什么会发生这种情况吗?
We are using strike-through to actually show oldprice vs new price for a product.
If you open this link, at the bottom of the page, we have a product on sale.
http://www.gkelite.com/Gymnastics-Shopby-GiftoftheWeek
The strike-through for the old price is not centered vertically for the text.
Can any one help out as to why it's happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我找到了一个利用伪元素 http://jsfiddle.net/urjhN/ 的解决方案
,但是如果文本在行之间换行,该行将在这些行之间居中。
它似乎适用于所有主要浏览器;对于 IE7(及更早版本),您可以使用条件注释回退到经典的
line-through
。I found a solution for it utilizing psuedo elements http://jsfiddle.net/urjhN/
However this technique fails if the text is wrapped between lines, the line would be centered among those lines.
It seems to work among all major browsers; for IE7 (and prior) you could just fallback to the classic
line-through
using conditional comments.传统上,删除线是 x 高度(或小写“x”的高度)的某个百分比(70% 到 90%)。如果该行位于大写字母高度的 50%,则删除线可能会位于该组中任何小写字母的上方或顶部。删除线应该是在文本中的所有字母之间划一条线,这就是为什么从 x 高度进行测量的原因。
无论浏览器是否实际上使用 x 高度进行删除线计算,这一传统就是为什么删除线显示在大写字母高度的 50% 以下的原因。
有关术语的一些示例,请参阅下图:
A strike-through is traditionally some percentage (70% to 90%) of the x-height (or the height of a lower case 'x'). If the line were at the 50% of cap-height, it may be possible the strike-through would be above or at the top of any lowercase letter in the set. A strike-through is supposed to put a line through all letters in the text, which is why is gauged from the x-height.
Whether or not browsers actually use the x-height for their strikethrough calculation, this tradition is why is why strike-throughs are displayed short of the 50% of cap height.
See the following illustration for some examples of the terms:
无法控制删除线的偏移/位置,但是,有一种方法可以使用
text-decoration: underline< 来控制它/code> 使用以下组合:
There is no way to control the offset/placement of a strike-through, but, there is a way for controlling this using for
text-decoration: underline
using the below combination:???? Here's a Codepen of mine with an alternative strike-through approach:
https://codepen.io/vsync/pen/KKQoVRZ
它帮助我。只需为 iOS 设备设置您的 top 即可。
It help me. Just setting your top for iOS devices.