我创建了一个基本菜单,上面有年份,下面有一个圆圈。将鼠标悬停在li上时,字体大小会增加,但这似乎在下面的圆上引起了抖动或抖动。

如何停止此操作并在悬停上产生流畅的效果?我已经将我的css和html包含在一个代码片段中,以便您可以了解我在说什么。



#timeline ul {
    text-align: center;
    text-transform: uppercase;
    margin: 0;
    padding: 0;
}

ul li {
    position: relative;
    display: inline-block;
    float: none;
    width: 5%;
    max-width: 140px;
    padding: 25px 0;
    transition: all .3s ease;
    box-sizing: border-box;
    text-align: center;
    font-family: alternate-gothic-no-3-d,Helvetica Neue,Helvetica,Arial,sans-serif;
    font-size: 20px;
}

#timeline ul .hovered, #timeline ul li:hover {
    transition: all .5s;
    font-size: 35px;
    cursor: pointer;
    padding-top: 12px;
    padding-bottom: 21px;
}

#timeline ul li .indicator {
    display: block;
}

#timeline ul li .title:before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 12px;
    height: 12px;
    border: 3px solid #a39688;
    border-radius: 100%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    transition: all .3s ease;
}

<div id="timeline">
<ul class="timeline-list">
                                    <li class="" data-number="1">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="2">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="hovered" data-number="3">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="4">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="5">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="6">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="7">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="8">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="9">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="10">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="11">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>

                                </ul>

                                </div>

最佳答案

尝试像我在代码中那样使.title绝对



#timeline ul {
    text-align: center;
    text-transform: uppercase;
    margin: 0;
    padding: 0;
}
span.title {
     position: absolute;
width: 100%;
text-align: center;
left: 0;
bottom: 20px;
}
ul li {
    position: relative;
    display: inline-block;
    float: none;
    width: 5%;
    max-width: 140px;
    padding: 25px 0;
    transition: all .3s ease;
    box-sizing: border-box;
    text-align: center;
    font-family: alternate-gothic-no-3-d,Helvetica Neue,Helvetica,Arial,sans-serif;
    font-size: 20px;
    height: 80px;
}

#timeline ul .hovered, #timeline ul li:hover {
    transition: all .5s;
    font-size: 35px;
    cursor: pointer;
    padding-top: 12px;
    padding-bottom: 21px;
}

#timeline ul li .indicator {
    display: block;
}

#timeline ul li:before {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 12px;
    height: 12px;
    border: 3px solid #a39688;
    border-radius: 100%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    transition: all .3s ease;
}

<div id="timeline">
<ul class="timeline-list">
                                    <li class="" data-number="1">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="2">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="hovered" data-number="3">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="4">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="5">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="6">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="7">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="8">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="9">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="10">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>
                                    <li class="" data-number="11">
                        <span class="indicator"></span>
                        <span class="title">1861</span>
                    </li>

                                </ul>

                                </div>

关于html - 悬停时如何停止圆圈上的抖动,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46586303/

10-13 06:32