负利润,黑客与否?

发布于 2024-09-16 00:44:49 字数 218 浏览 3 评论 0原文

我见过各种帖子,人们都说负边距是黑客行为。因此,我已经偏离使用它们,除非我可以合理地使用它们的特定情况,例如使用 margin:-9999px 将文本从屏幕上扔掉

问题,负边距是一种黑客攻击吗?正确使用负边距?我见过它们在 960 网格系统中与 .push.pull 一起使用,在任何其他情况下它们都可以合理使用吗?!?!

I've come across various posts where people are stating that negative margins are hacks. Thus I've strayed away from using them with exception to particular cases when I can justifiably use them, like throwing text off the screen with margin:-9999px

Question, are negative margins a hack and when is it right to use negative margins? I've seen them used in the 960 Grid System with, .push and .pull, any other cases where they are justifiably usable?!?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甜是你 2024-09-23 00:44:49

根据 W3C 规范,允许使用负边距。我用它们让东西悬在容器上方。

Negative margins are allowed based on W3C specifications. I have used them to let things overhang their container.

流年已逝 2024-09-23 00:44:49

我认为这不是黑客:它是定义的、逻辑的行为;所有浏览器都支持它;预计未来版本的浏览器将支持它(未来不支持是反对黑客攻击的最重要论据)。

此外,正如 @durilai 指出的,它们受到 W3C 的正式认可(尽管有限制)。

这篇Smashing 杂志文章支持该案。

I would argue it's not a hack: It's defined, logical behaviour; it's supported in all browsers; it can be expected to be supported in future versions of browsers (the absence of future support is the most important argument against hacks).

Also, as @durilai points out, they are officially sanctioned (although with limits) by the W3C.

This Smashing Magazine article supports the case.

最近可好 2024-09-23 00:44:49

我怀疑他们因为浏览器行为不一致而被标记为黑客。

只要有可能,我都会使用 position:relative 和负的顶部和左侧值将元素拉到新位置。这并不适用于所有情况,但我发现它在所有 Internet Explorer 风格中的行为更加一致。

I suspect they've been labeled as a hack because of inconsistent browser behavior.

Whenever possible I use position: relative and negative top and left values to pull elements into new locations. This isn't possible for every case, but I find it behaves more consistently in all the Internet Explorer flavors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文