html - 在其 css 中具有过渡的元素的意外行为

标签 html css positioning transition

我为某些元素编写了一些 css,但它导致了一些意外行为。我正在使用:

transition: 0.2s;

当刷新页面时,具有此 css 属性的元素意外地从页面的另一个区域开始,并移动到它们的设置位置(设置在我的 css 的其他部分)。的,

position: absolute

属性用于定位元素,是什么导致了这种意外行为?

这是链接的 CSS:

.subLinks_links {
    position: relative;
    width: 100%;
    height: 50px;
    line-height: 50px;
    text-align: left;
    border-top: 1px solid #ebebeb;
    border-bottom: 1px solid #ebebeb;
    font-size: 13px;
    color: #999;
    margin-bottom: -1px;
    cursor: pointer;
    text-transform: uppercase;
}

.subLinks_links > span {
    margin-left: 30px;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;

.subLinks_links:hover > span {
    margin-left: 40px;
}

以及 css 的相关 HTML:

<div id="subLinks">

    <div class="subLinks_links_selected"><span>Link Text</span></div>

    <div class="subLinks_links"><span>Link Text</span></div>

</div>

最佳答案

我发现这是一个定位问题。我使用 text-align 和 margin-left 来定位元素。没有导致不良行为的死定位。

关于html - 在其 css 中具有过渡的元素的意外行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26703306/

相关文章:

css - 'relative' 定位如何将工具提示放置在正确的位置?

html - 按钮单击边框半径样式问题

html - 如何修复 Mobile-View 的表格?

asp.net - 如何制作最大尺寸设置为包含 DIV 的 GridView

ASP.Net 验证器样式

javascript - CSS clearfix 问题 float

html - 混淆了 html 中类的语法分配

html - 由于 html 代码的微小变化,php 链接丢失

javascript - 没有 jQuery 的滚动图片库

html - 隐形覆盖 DIV 阻塞悬停? +定位