CSS Border on three sides

左心房为你撑大大i 提交于 2020-01-02 00:55:12

问题


If i want to have border on the three sides, do I need to declare border for each side eg.

border-left:1px solid green;
border-bottom:1px solid green;
border-right:1px solid green;

or is there any shortcut way?


回答1:


border: 1px solid green;
border-top: 0;



回答2:


Well, there is a slightly shorter way - but it's not what you'd call a shortcut...

border: 1px solid green;
border-top: 0;

Or you could declare partial elements which would allow for clarity:

border-color: green;
border-style: solid;
border-width: 0 1px 1px 1px;



回答3:


You don't need to declare the border-top style and then override it:

border: 1px green;
border-style: none solid solid;



回答4:


border:1px solid green;
border-top: none;

Note: I wouldn't do this myself, personally; it could be confusing to those reading it, and there's really no need. Although the original way involves repetition, it's minimal.




回答5:


this is a little shorter and does the same:

border:1px solid green;
border-top:0;


来源:https://stackoverflow.com/questions/8382826/css-border-on-three-sides

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!