CSS简写中的通配符?

发布于 2024-12-23 12:33:03 字数 387 浏览 3 评论 0原文

我目前在某些东西上有 margin-top:25px ,并且我想使用以下简写更改其他 3 个属性:

/*Shorthand: <top> <right+left> <bottom>*/
margin: * 10px 50px;

我应该用什么替换 * 才能将其保留在 25px 上? (并且不要说25px,因为有时我不知道之前的margin-top值!)

有没有办法做到这一点?或者我必须使用:

margin-right:10px;
margin-bottom:50px;
margin-left:10px;

但我真的想使用简写 >_<

I currently have margin-top:25px on something, and I want to change the other 3 attributes using this shorthand:

/*Shorthand: <top> <right+left> <bottom>*/
margin: * 10px 50px;

What should I replace the * for in order to leave it on 25px? (and don't say 25px, because sometimes I won't know the previous margin-top value!)

Is there a way to do this? Or I must use:

margin-right:10px;
margin-bottom:50px;
margin-left:10px;

But I really want to use the shorthand >_<

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

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

发布评论

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

评论(1

小耗子 2024-12-30 12:33:03

也许我误解了这个问题,但是您是否想继承顶部边距的价值,这就是为什么您并不总是知道该价值?如果是这种情况,您可以尝试:

margin: inherit 10px 50px;

Maybe I'm misunderstanding the question, but are you wanting to inherit the value of the top-margin, and that's why you don't always know the value? If that's the case, you might try:

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