Featured filled corner css

╄→гoц情女王★ 提交于 2019-12-08 16:29:35

Your problem is that you're trying to place a pseudo-element into a div with no height or width...so it won't fit.

If you position two pseudo-elements, the first being the Font Awesome ::before and the second the triangle background I think you get more control.

You can swap out the icon, color it how you like and you also have control of the background independent of everything else.

Something like this:

.featured.fa {
  width: 100px;
  height: 100px;
  margin: 2em auto;
  border: 1px solid grey;
  display: block; /* needed to override FA styling */
  position: relative;
}
.featured.fa::before {
  position: absolute;
  right: 0%;
  top: 0;
  margin: .25em;
  color: gold;
}
.featured::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  top: 0;
  right: 0;
  border-width: 20px;
  border-style: solid;
  border-color: darkorange darkorange transparent transparent;
  z-index: -1;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />

<div class="featured fa fa-star"></div>
Jorge Anzola

Ok, using Paulie-D's answer (Thanks!) and doing this. (Because copy-paste the answer didn't work)

HTML

<div class="ribbon-wrapper-featured"><div class="featured fa fa-star"></div></div>

CSS

/*corner ribbon*/
.ribbon-wrapper-featured {
    position: absolute;
    top: -50px;
    right: 0px;
}

.featured.fa {
    width: 100px;
    height: 100px;
    display: block;
    position: absolute;
    top: 20px;
    right: -30px;
}
.featured.fa::before {
    position: absolute;
    right: 0%;
    top: 0;
    margin: .25em;
    color: gold;
    z-index: 2;
}
.featured::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    top: 0;
    right: 0;
    border-width: 20px;
    border-style: solid;
    border-color: darkorange darkorange transparent transparent;
    z-index: 1;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!