Display Pseudo element above parent when parent's overflown is hidden

Viewed 382

div {
  margin: 50px;
  position: relative;
  background-color: red;
  width: 200px;
  height: 50px;
  border: 2px solid black; 
}

div::after {
  content: '';
  position: absolute;
  background-color: green;
  width: 100px;
  height: 100px;
  border-radius: 100%;
  top: -25px;
  left:50px;

  border: 2px solid black; 
}

div.overflow-hidden {
  overflow: hidden;
}
<div>1st</div>
<div class="overflow-hidden">2nd</div>

1st case: as expected.

2nd case[overflow-hidden]: Middle part of top and bottom border should be green. Looks like circle is not above its parent div's border. Is there any way to make it above it? Whats happening here? Will the z-index work?

1 Answers
Related