Skip to content
Advertisement

CSS Border animation takes space inside table, rough animation when using position absolute

I’m trying to make a notification button with animation effect using border, but the animation is affecting the width and height of cell:

            .tooltips {
                font-size: 11px;
                margin-top: -17px;
            }
            .tooltip-notif{
                animation: ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
                border-radius: 49%;
            }
            @keyframes ripple {
                0% {
                    border: 0 solid black;
                }
                100% {
                    border: 10px solid rgba(0, 0, 0, 0);
                }
            }
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.9/css/all.css" integrity="sha384-5SOiIsAziJl6AWe0HWRKTXlfcSHKmYV4RBF18PPJ173Kzn7jzMyFuTtk8JA7QQG1" crossorigin="anonymous">
<table>
<tbody>
    <tr>
        <td style="display: none;" class="sorting_1">55</td>
        <td style="white-space: nowrap">Class F<i class="tooltips tooltip-notif fa fa-info-circle" style="" title="Click here to see some changes" data-title=""></i></td>
        <td style="display: none;">2021-06-10</td>
        <td style="display: none;">2021-06-21</td>
    </tr>
    
    <tr>
        <td style="display: none;" class="sorting_1">56</td>
        <td style="white-space: nowrap">Class C<i class="tooltips tooltip-notif fa fa-info-circle" style="" title="Click here to see some changes" data-title=""></i></td>
        <td style="display: none;">2021-06-10</td>
        <td style="display: none;">2021-06-21</td>
    </tr>
</tbody>
</table>

What have I tried:

            .tooltips {
                font-size: 11px;
                margin-top: -17px;
            }
            .tooltip-notif{
                animation: ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
                border-radius: 49%;
            }
            @keyframes ripple {
                0% {
                    border: 0 solid black;
                    margin-top: 10px;
                    margin-left: 10px;
                }
                100% {
                    border: 10px solid rgba(0, 0, 0, 0);
                    margin-top: 0;
                    margin-left: 0;
                }
            }
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.9/css/all.css" integrity="sha384-5SOiIsAziJl6AWe0HWRKTXlfcSHKmYV4RBF18PPJ173Kzn7jzMyFuTtk8JA7QQG1" crossorigin="anonymous">
<table>
<tbody>
    <tr>
        <td style="display: none;" class="sorting_1">55</td>
        <td style="white-space: nowrap">Class F<i class="tooltips tooltip-notif fa fa-info-circle" style="" title="Click here to see some changes" data-title=""></i></td>
        <td style="display: none;">2021-06-10</td>
        <td style="display: none;">2021-06-21</td>
    </tr>
    
    <tr>
        <td style="display: none;" class="sorting_1">56</td>
        <td style="white-space: nowrap">Class C<i class="tooltips tooltip-notif fa fa-info-circle" style="" title="Click here to see some changes" data-title=""></i></td>
        <td style="display: none;">2021-06-10</td>
        <td style="display: none;">2021-06-21</td>
    </tr>
</tbody>
</table>

This code should executedly fine by theory, though it’s rough when it animates. Using position: absolute and fixed broke the entire notification’s position.

I tried applying overflow:hidden or scroll, doesn’t really do the job.

PS.

This is not a duplicate question, there are tons of questions related to this, but those related questions doesn’t fix this problem (e.g. box-sizing: border-box).

Advertisement

Answer

Wrapping the font-awsome <i> elements in an inline block container that prevents the animation from changing the position of other elements is a possible solution. This example uses a <span> wrapper with class .effect for this purpose:

.effect {
   overflow: visible;
   display: inline-block;
   width: 30px;
   text-align: center;
   height: 15px;
}
.tooltips {
                font-size: 11px;
                margin-top: -17px;

            }
            .tooltip-notif{
                animation: ripple 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
                border-radius: 49%;
            }
            @keyframes ripple {
                0% {
                    border: 0 solid black;
                }
                100% {
                    border: 10px solid rgba(0, 0, 0, 0);
                }
            }
<!-- body-html -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.9/css/all.css" integrity="sha384-5SOiIsAziJl6AWe0HWRKTXlfcSHKmYV4RBF18PPJ173Kzn7jzMyFuTtk8JA7QQG1" crossorigin="anonymous">
<table>
<tbody>
    <tr>
        <td style="display: none;" class="sorting_1">55</td>
        <td style="white-space: nowrap">Class F<span class="effect"><i class="tooltips tooltip-notif fa fa-info-circle" style="" title="Click here to see some changes" data-title=""></i></span></td>
        <td style="display: none;">2021-06-10</td>
        <td style="display: none;">2021-06-21</td>
    </tr>
    
    <tr>
        <td style="display: none;" class="sorting_1">56</td>
        <td style="white-space: nowrap">Class C<span class="effect"><i class="tooltips tooltip-notif fa fa-info-circle" style="" title="Click here to see some changes" data-title=""></i></span></td>
        <td style="display: none;">2021-06-10</td>
        <td style="display: none;">2021-06-21</td>
    </tr>
</tbody>
</table>
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement