css - Pseudoelement RGBA arrow color doesn't match parent -
i'm creating pseudoelement arrow under div
(#telegram-join
), both of have background/border colors rgba values (rgba(255, 255, 255, 0.25)
), arrow being affected differently , appears darker div
. because it's smaller? how can match them? thanks!
html
<div id="telegram-join" class="bg-combo"> <h1><i class="fa fa-telegram"></i> chat on telegram</h1> </div>
css:
.bg-combo { display: flex; align-items: center; justify-content: center; margin: 0 auto; border-radius: 8px; padding: 5px 10px; width: fit-content; background-color: white; background-color: rgba(255, 255, 255, 0.25); text-align: center; } .bg-combo h1 { display: inline-block; font-size: 2em; line-height: 1.5; text-transform: uppercase; } .bg-combo h1 { margin-right: 10px; } #telegram-join { position: relative; margin: 15px auto 25px; } #telegram-join :after { position: absolute; top: 100%; left: 50%; transform: rotate(-45deg); transform-origin: 50% 50%; margin-left: -15px; margin-top: -15px; border: 15px solid #fff; width: 0; height: 0; border-color: transparent transparent rgba(255, 255, 255, 0.25) rgba(255, 255, 255, 0.25); content: ''; }
demo: codepen
your background-color (of container) has 0.25% opacity, , pseudo-element (which inside element) has 0.25% opacity (so it's background no longer body-background, it's new background of container element - has opacity).
you can solve setting opacity of pseudo-element 0.125%:
border-color: transparent transparent rgba(255,255,255,0.125) rgba(255,255,255,0.125);
or set background on both elements actual color want:
border-color: transparent transparent #d7d7d7 #d7d7d7;
here update codepen:
https://codepen.io/anon/pen/eexqao
wiki
Comments
Post a Comment