简体   繁体   English

一侧彩色边框

[英]One side colored border

I recently saw this kind of border ( source ) 我最近看到了这种边界( 来源 在此处输入图片说明

I am talking about the left, yellow border. 我说的是左边的黄色边框。 What I find special about it, is that it is completely straight on the right side of it, so you could put a vertical line next to it that would either hit completely or not at all any of the yellow part: 我发现它的特别之处在于它在它的右侧是完全笔直的,因此您可以在其旁边放置一条垂直线,该垂直线将完全击中或根本不击中任何黄色部分:

在此处输入图片说明

How can one do such a border in CSS? 如何在CSS中做这样的边框? I explicitely do not want to do something like this: 我明确地不想做这样的事情:

 div { border-left:5px solid blue; border-radius:10px; height:50px; } 
 <div></div> 

在此处输入图片说明

If you put a vertical line next to hit, it will hit the edges of the border: 如果在命中旁边放置一条垂直线,它将命中边框的边缘:

在此处输入图片说明

I hope I described it so one can understand it. 我希望我能描述它,以便人们能理解。 Otherwise please feel free to edit this post, thanks. 否则,请随时编辑这篇文章,谢谢。

A simple background will do it: 一个简单的背景就可以做到:

 .box { margin:10px; width:200px; height:100px; border-radius:15px; background: /*width height*/ linear-gradient(gold,gold) left/10px 100% no-repeat, #f2f2f2; } 
 <div class="box"> </div> 

Another syntax: 另一种语法:

 .box { margin: 10px; width: 200px; height: 100px; border-radius: 15px; background: linear-gradient(to right, gold 10px, #f2f2f2 0); } 
 <div class="box"> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM