简体   繁体   English

伪元素选择器不起作用

[英]Pseudo element selector not working

I have a dynamic element which will be capable of scaling in size, its position could be placed anywhere on the screen. 我有一个动态元素,可以缩放大小,它的位置可以放在屏幕上的任何位置。 I'm basically trying to create an "elbow" section. 我基本上是试图创建一个“弯头”部分。

What this "elbow" needs is an extension arm at the top right... Funny thing is, while I have the position and size correct, for some reason, the pseudo element is not showing up in the grey I'm calling... (see attached image showing Element Inspector highlighting the element in the correct size and position, but not in the same grey)... 这个“弯头”需要的是右上角的延伸臂...有趣的是,尽管我的位置和大小正确,但由于某种原因,伪元素没有显示为灰色。 。(请参阅所附图片,其中显示了“元素检查器”以正确的大小和位置突出显示了元素,但未使用相同的灰色)...

在此处输入图片说明

I have a JSFiddle here of the code: https://jsfiddle.net/eliseo_d/6p9z8xr3/ 我在这里有一个JSFiddle代码: https ://jsfiddle.net/eliseo_d/6p9z8xr3/

HTML: <div class="elbow-1-toprt-wide0-grey1">elbow 1</div> HTML: <div class="elbow-1-toprt-wide0-grey1">elbow 1</div>

CSS: CSS:

html {
  background-color: rgb(0,0,0);
}

body {
  margin: 5px;
}

div[class$='-grey1'] {
  background-color: rgb(102,102,102);
}

div[class^='elbow-'] {
  /* default settings */
  color: rgb(0,0,0);
  font-size: 14pt;
  height: 14px;
  margin-bottom: 4px;
  margin-right: 4px;
  overflow: hidden;
  padding-bottom: 7px;
  padding-left: 10px;
  padding-right: 10px;
  text-align: right;
  text-transform: uppercase;
  width: 84px;
  position: relative;
}

div[class^='elbow-1-'] {
  padding-top: 46px;
}

/* Initial curve */
div[class^='elbow-'][class*='-toprt-'] {
    border-top-left-radius: 42px;
}

/* elbow bar */
div[class^='elbow-'][class*='-toprt-']:after {
  content: '';
    height: 30px;
    left: 104px;
    top: 0;
    position: absolute;
}
div[class^='elbow-'][class*='-wide0-']:after {
    width: 21px;
}
div[class^='elbow-'][class*='-wide0-'][class$='-grey0']:after {
  background-color: rgb(51,51,51);
}
div[class^='elbow-'][class*='-wide0-'][class$='-grey1']:after {
  background-color: rgb(102,102,102);
}

I can't seem to figure out what I'm missing? 我似乎无法弄清楚我所缺少的是什么?

Anyone know what I'm missing? 有人知道我想念什么吗? Thanks in advance. 提前致谢。

The ::after element is being shown with the background, your problem is that div[class^='elbow-'] is set to overflow:hidden; ::after元素与背景一起显示,您的问题是div[class^='elbow-']设置为overflow:hidden; , which is hiding the pseudo element. ,它隐藏了伪元素。

Simply remove overflow:hidden; 只需删除overflow:hidden;

JSFiddle Demo JSFiddle演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM