1 year ago

#373044

test-img

irishrunner16

CSS: Skewed button using pseudo position: absolute

I have a button with only a single tag (<a>). I want to skew the background of the button and keep the text as is, so I'm using this code, which is working as expected in my Codepen example:

<a class="et_pb_button et_pb_pricing_table_button" href="#">$200 / Month</a>
.et_pb_pricing_table_button {
    margin: 10px;
    cursor: pointer;
    background-color: transparent;
    border: none;
    height: 50px;
    padding: 10px 60px;
    position: relative;
    color: #000000;
    font-weight: bold;
  text-decoration: none;
}
.et_pb_pricing_table_button:after {
    z-index: -1;
    content: '';
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: skewX(-15deg);
    border-radius: 0px;
    background-color: #ffd100;
}
.et_pb_pricing_table_button:hover:after{
    background-color: skyblue;
}

However, when I apply that code to my page, it is not rendering as expected (not visible). I can't find anything that is stopping this from working (the parent elements are position: relative). I also tried increasing the z-index of the pseudo selectors, but that didn't help either. What am I missing?

html

css

css-selectors

css-position

0 Answers

Your Answer

Accepted video resources