开发者

Is there a way to assign 3 borders (say left, right & top) all at once instead of individually?

开发者 https://www.devze.com 2023-02-17 19:48 出处:网络
If you\'re setting all the borders to be the same, you can simply do something like border: 1px solid #DDD. Now, if I need to do only 3 of them, I\'m forced to write each one out likeborder-left: 1px

If you're setting all the borders to be the same, you can simply do something like border: 1px solid #DDD. Now, if I need to do only 3 of them, I'm forced to write each one out like border-left: 1px solid #DDD, border-top: 1px solid #DDD, etc. Is there a way I can combine them into one line? Something like border-{left,right,top}: 1px solid #DDD

The simplest two line option I have is to first set all borders and turn one of them off. B开发者_Go百科ut I reset all borders to zero at the start of the script, so this is kind of redundant.


3 lines

div {
  border-color: red;
  border-style: solid;
  border-width: 1px 1px 1px 0;
}

2 lines

div {
  border: 1px solid red;
  border-left: 0;
}

See http://css-tricks.com/three-sided-border/


I guess there is no solution for this. The short hand technique for border attribute is not available to set multiple borders.

you can try this:

border: #ffffff solid;
border-width: 3px 2px 1px 0;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号