简体   繁体   English

矩形,一侧倾斜

[英]rectangular with one oblique side

I'm looking for a CSS approach to make one div's side oblique, but with border radius at the top. 我正在寻找一种CSS方法,使一个div的侧面倾斜,但边框半径在顶部。 for example 例如

在此处输入图片说明

solution with transform skew doesnt work, because I need correct border-radius. 转换偏斜的解决方案不起作用,因为我需要正确的边界半径。 thanks in advance! 提前致谢!

How about this? 这个怎么样? I made the two parts of the tab different colors, so you can see their outline. 我为选项卡的两个部分设置了不同的颜色,以便您可以看到它们的轮廓。

 .tab { display: inline-block; border: 1px solid black; } .tab .left { background-color: pink; border: solid red; border-width: 3px 0 0 3px; border-radius: 10px 0 0 0; height: 20px; padding: 0 10px; float: left; } .tab .right { background-color: #8080FF; border: solid blue; border-width: 3px 3px 0 0; width: 20px; height: 20px; border-radius: 0 10px 0 0; float: left; transform: skew(30deg); transform-origin: 0 100%; } 
 <div class="tab"> <div class="left">TextTexT</div> <div class="right"></div> </div> 

demo - http://jsfiddle.net/bu4aps5a/ 演示-http: //jsfiddle.net/bu4aps5a/

use pseudo element :after 使用伪元素:after

 div { width: 100px; height: 40px; border: 1px solid grey; border-right: 1px solid transparent; border-top-left-radius: 5px; border-top-right-radius: 6px; position: relative; background: rgb(219, 219, 219); text-align: center; line-height: 40px; } div:after { content: ''; width: 20px; height: 100%; position: absolute; transform: skewX(25deg); border: 1px solid grey; border-left: 1px solid transparent; top: -1px; right: -11px; border-top-right-radius: 6px; background: rgb(219, 219, 219); } 
 <div>test</div> 

Here is a svg solution without any CSS: 这是一个没有任何CSS的svg解决方案:

 <svg width="95" height="46"> <path d="M1,9 Q1,1 9,1 L70,1 Q76,0 80,9 L95,45 L1,45z" fill="#EEEEEE" stroke="#818185" stroke-width="1" /> <text x="25" y="29" font-size="18" font-weight="500" fill="#414145">Hits</text> </svg> 

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

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