用于指定所需边框的终极 CSS 快捷方式

发布于 2024-11-01 20:36:25 字数 328 浏览 9 评论 0 原文

需要一些家庭作业的帮助。我希望有人可以帮助我,因为我已经尝试了所有组合但没有取得多大成功。我被要求简化以下内容:

border-top: 1px solid #8B8BA2; 
border-left: 1px solid #8B8BA2; 
border-bottom: 1px solid #8B8BA2;

任何人都有任何好主意。我确实尝试了以下方法,但似乎不起作用:

border: 1px solid none solid solid #8B8BA2;

希望有人可以提供帮助。

马里

Needing help for some homework. I hope someone can help me out as I have tried all combinations with not much success. I've been asked to simplify the following:

border-top: 1px solid #8B8BA2; 
border-left: 1px solid #8B8BA2; 
border-bottom: 1px solid #8B8BA2;

Anyone have any great ideas. I did try the following but it didn't seem to work:

border: 1px solid none solid solid #8B8BA2;

Hope someone out there can help.

Mari

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

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

发布评论

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

评论(2

蘸点软妹酱 2024-11-08 20:36:25

通过指定 border 属性,您可以一次指定所有边框。由于四分之三是相同的,请指定所有边的边框,然后删除不适用的边的边框:

border: 1px solid #8B8BA2;
border-right: 0;

Specifying the border attribute let's you specify all borders at once. Since three out of four are the same, specify the border for all sides, and then remove the border for the one it doesn't apply to:

border: 1px solid #8B8BA2;
border-right: 0;
没有心的人 2024-11-08 20:36:25

作为 SeanA 的答案(+1)的补充,-如果这是为了家庭作业,你可能会被问到你是否真的知道速记边界顺序..所以虽然上面的方法也有效,但这可能就是他们想要的答案。

border: 1px solid #8B8BA2;
border-width: 1px 0 1px 1px; 

第一个声明所有边框,第二个零是“右”边框,使用四边符号。边框(以及边距和填充)写为 Top - Right - Bottom - Left - TRBL 用于记住这一点的单词是“TRouBLe”或者你可以顺时针思考:)

As an addition to SeanA's answer (+1), - if this is for homework you might be being asked if you actually know the shorthand border order.. so while the above works too, this might be the answer they're after.

border: 1px solid #8B8BA2;
border-width: 1px 0 1px 1px; 

the first declares all borders, the second zero's the "right" border, using the four sided notation.. border (and margins and padding) are written Top - Right - Bottom - Left - TRBL and the word used to remember this is "TRouBLe" or you can just think clockwise :)

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