Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - Oblique border without filling

Tags:

html

css

I've a div and I need a border with the left side oblique, but I'm finding only solutions that have the element filled with color. I need only the border, like this picture:

enter image description here

How can I do this?

My actual code:

HTML

<div class="arrow">
    <span id="time">30 mins</span>
    <img src="assets/up_arrow.png" />
</div>

CSS

.arrow {
    display: inline-block;
    text-align: right;
    text-decoration: none;
    margin-left: 35%;
    padding: 5px 0 5px 0;
    border-style: solid;
    border-width: 1px 0 1px 0;
    border-color: #929A9D transparent #929A9D transparent;
 }

 .arrow > img {
     vertical-align: middle;
     width: 12px;
     height: 12px;
 }
like image 242
Nodiink Avatar asked Oct 25 '25 03:10

Nodiink


2 Answers

TRY THIS DEMO

HTML & CSS

#a {
    position: relative;
    width: 120px;
    padding: 10px 20px;
    font-size: 20px;
    position: relative;
    margin-left:50px;

    color: #2E8DEF;

    border: 3px solid #2E8DEF;
    border-left:0;
}
#a:before {
    content: " ";
    position: absolute;
    display: block;
    width: 50%;
    height: 100%;
    top: -3px;
    left: -30px;
    z-index: -1;

    border:3px solid #2E8DEF;
    border-right: 0px;

    transform-origin: bottom left;
    -ms-transform: skew(-30deg, 0deg);
    -webkit-transform: skew(-30deg, 0deg);
    transform: skew(-30deg, 0deg);
}
<div id="a">

    Hello

</div>
like image 131
Alfin Paul Avatar answered Oct 27 '25 18:10

Alfin Paul


I have created the shape using border and before pseudo element. Hope this will help.

.ClassicBorder {
  width: 200px;
  padding: 4px 0;
  border: 2px solid #999;
  position: relative;
  margin-left: 9px;
  text-align: center;
  font-size: 25px;
}

.ClassicBorder:before {
  height: 36px;
  width: 40px;
  border: 2px solid #999;
  content: '';
  position: absolute;
  border-right: 0px;
  border-top: 0px;
  transform: skew(340deg);
  -webkit-transform: skew(340deg);
  -moz-transform: skew(340deg);
  background: #fff;
  left: -9px;
  top:0px;
}
<div class="ClassicBorder">
  30 Mins >
</div>
like image 44
Sahil Dhir Avatar answered Oct 27 '25 16:10

Sahil Dhir



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!