I've written coded some speech bubble for displaying hints on what to do in a smartphone app. It shall be responsive, hence I chose to use CSS ... However, there are some issues with it. The "pointing" part of the speech bubble (which is added with a ::before or ::after) has a little gap, when it's animated. And the invisible region of the pointing part is also quite huge. Since this is on top of the elements to be clicked/touched on, it prevents the action, if the user touches exactly where the pointer points to.
This is issue #1 (Gap between rounded box and triangle/pointing part; only during animation.. because both parts seem to be moved separately):
This is issue #2 (Too large invisible bounding box, that overlays the button; Yellow region in the following image, this prevents the button to be clicked if the user touches that invisible region):
I mainly need to reduce this invisible region (Issue #2).
My current solution can be found at: https://jsfiddle.net/1mw0g79a/ or just below. Please keep the usage of "vh", "vw" and "%" for size related measures in the CSS, as this is how I ensure a similar look of the app on different devices... This is also the reason why I cannot simply use 'any' open source solution for speech bubbles out there.
The HTML:
<html><head><title>...</title></head><body>
<div id="button" class="button">Button</div>
<div id="hint" class="bubble downwards">
Hello! I'm a hint message...
</div>
</body></html>
And the CSS:
.bubble {
position: fixed;
top: 33.5vh;
left: 3vw;
max-width: 90vw;
width: 90vw;
z-index: 10000;
background-color: #00000088;
color: white;
font-size: 2.3vh;
padding: 2vh 2vw;
border-radius: 2vh;
box-shadow: 0 1vh 1vw rgba(0, 0, 0, .3), 0 0.1vh 0.2vw rgba(0, 0, 0, .2);
display: flex;
align-content: center;
animation-duration: 2s;
animation-iteration-count: infinite;
animation-name: bounce;
animation-timing-function: ease;
}
.bubble.downwards::after {
content: '';
position: absolute;
width: 0;
height: 3vh;
bottom: -9vh;
border-top: none;
left: 40vw;
border: 3vh solid transparent;
z-index: 10001;
border-top-color: #00000066;
filter: drop-shadow(0 1vh 1vw rgba(0, 0, 0, .3)), drop-shadow(0 0.1vh 0.2vw rgba(0, 0, 0, .2));
}
@keyframes bounce {
0% { margin-top: -0vh; }
50% { margin-top: -1vh; }
100% { margin-top: 0vh; }
}
.button {
border-radius: 0.5vh;
background-color: #aaa;
font-size: 2.3vh;
padding: 1vh;
text-align: center;
}
#button {
position: absolute;
top: 40vh;
width: 20vw;
left: auto;
right: auto;
}
#hint {
top: 30vh;
left: 3vw;
}
#hint::after {
left: 5vw;
}