CSS Border on three sides

2019-04-18 14:26发布

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?

标签: css border
5条回答
姐就是有狂的资本
2楼-- · 2019-04-18 14:49

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

border: 1px green;
border-style: none solid solid;
查看更多
叼着烟拽天下
3楼-- · 2019-04-18 14:57
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.

查看更多
ら.Afraid
4楼-- · 2019-04-18 14:59
border: 1px solid green;
border-top: 0;
查看更多
ら.Afraid
5楼-- · 2019-04-18 15:02

this is a little shorter and does the same:

border:1px solid green;
border-top:0;
查看更多
霸刀☆藐视天下
6楼-- · 2019-04-18 15:07

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;
查看更多
登录 后发表回答