Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rectangular with one oblique side

Tags:

css

geometry

I'm looking for a CSS approach to make one div's side oblique, but with border radius at the top. for example

enter image description here

solution with transform skew doesnt work, because I need correct border-radius. thanks in advance!

like image 255
kutsokon Avatar asked Jul 20 '26 09:07

kutsokon


2 Answers

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

use pseudo element :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>
like image 120
Vitorino fernandes Avatar answered Jul 21 '26 23:07

Vitorino fernandes


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>
like image 39
Markus Jarderot Avatar answered Jul 21 '26 23:07

Markus Jarderot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!