-1

I have a css class that has a pseudo :before class attached to it. The :before class is just a border but it is overlapping the text. I have tried padding but it's still overlapping. Here is css code

 .chevron {
        width: auto;
        min-width: 100px;
        position: relative;
        background: #d1dce6;
        text-overflow: ellipsis;
        height: 40px;
        max-height: 40px;
    }
    .chevron:before  {
        content: "";
        position: absolute;
        left: 0;
        bottom: 0;
        width: 0;
        height: 0;

        border-left: 20px solid white;
        border-top: 20px solid transparent;
        border-bottom: 20px solid transparent;
    }

enter image description here

How can I get some space between the white border (:before) and text

Edit 1: The css class is applied to a element. Padding-left doesnt work.

 <th class="chevron" v-for="p in joinTo">{{p.description.trunc(30)}}</th>
Abhi.Net
  • 722
  • 3
  • 11
  • 37

2 Answers2

2

Just add some padding in the parent element:

.chevron {
    width: auto;
    min-width: 100px;
    position: relative;
    background: #d1dce6;
    text-overflow: ellipsis;
    height: 40px;
    max-height: 40px;
    /* Add this line: */
    padding-left: 50px;
}

Tip: Since you already have left: 0, you don't need to worry about the left alignment issues.

Also, as pointed out in the comments, if you don't want the overall size to increase because of padding you can use either of the two:

padding-left: 50px;
box-sizing: border-box;
text-indent: 50px;
Soolie
  • 1,812
  • 9
  • 21
0

You need add padding for parent element

 .chevron {
        width: auto;
        min-width: 100px;
        position: relative;
        background: #d1dce6;
        text-overflow: ellipsis;
        height: 40px;
        max-height: 40px;
        padding-left: 40px;
    }
    .chevron:before  {
        content: "";
        position: absolute;
        left: 0;
        bottom: 0;
        width: 0;
        height: 0;

        border-left: 20px solid white;
        border-top: 20px solid transparent;
        border-bottom: 20px solid transparent;
    }
<table>
  <thead>
      <tr>
          <th class="chevron">sdsdsd</th>
          <th class="chevron">sdsdsd</th>
          <th class="chevron">sdsdsd</th>
          <th class="chevron">sdsdsd</th>
          <th class="chevron">sdsdsd</th>
      </tr>
  </thead>
</table>
Dmytro Lishtvan
  • 788
  • 7
  • 12
  • Should have added one more thing.... The class is applied to a th element. I have tried padding-left , doesnt work. – Abhi.Net Nov 20 '17 at 09:28
  • @Abhi.Net added table. That's why i want your fiddle - because all work fine) try add !important to your padding – Dmytro Lishtvan Nov 20 '17 at 09:32