html - 过渡不适用于任何属性(property)?

标签 html css transition

我正在尝试过渡一个按钮以平滑地稍微向左移动,我可以使按钮移动与 padding-right 所以它不是语法问题。对于我使用的任何属性,转换似乎根本不起作用。

无效的代码:

    #home:hover
{
    padding-right: 10px;

    transition: padding-right 0.3s ease;
}

CSS:

/****Font Faces****/
@font-face {
    font-family: 'bebas book';
    src: local('?'),
        url('../fonts/bebas book.woff') format('woff');
}

@font-face {
    font-family: 'bebas light';
    src: local('?'),
        url('../fonts/bebas light.woff') format('woff');
}

@font-face {
    font-family: 'bebas regular';
    src: local('?'),
        url('../fonts/bebas regular.woff') format('woff');
}


/****Hover Modifiers****/
header:hover #home, header:hover #portfolio,
header:hover #about, header:hover #contact
{
    opacity: 1;

    transition: opacity 0.3s ease;
}

header:hover #menuIcon {
    margin: 20px 50px;

    transition: margin 0.3s ease;
}

header:hover {
    width: 120px;

    transition: width 0.3s ease;
}

#home:hover
{
    padding-right: 10px;

    transition: padding-right 0.3s ease;
}


/****Page Modifiers****/
body {
    margin: 0; padding: 0;
}


/****Header Modifiers****/
header {
    margin: 0; padding: 0;
    height: 100vh; width: 60px;

    position: fixed;

    opacity: 0.85;

    background: #120C08;

    transition: width 0.3s ease;
}

#menuIcon {
    margin: 20px;

    transition: margin 0.3s ease;
}

#home, #portfolio,
#about, #contact 
{
    right: 10px;

    position: absolute;

    opacity: 0;

    text-decoration: none;

    color: #FAECD4;

    font-family: bebas book;
    font-size: 25px;

    transition: opacity 0.3s ease;
}

#home {top: 80px;} #portfolio {top: 120px;}
#about {top: 160px;} #contact {top: 200px;}


/****Body Content****/
#mainImgWrapper {
    height: 100vh; width: 100%;

    background: url("../images/mainImage.jpg") no-repeat center center fixed;
}

最佳答案

添加这个

#home {
    padding-right: 0px;
    transition: opacity 0.3s ease, padding-right 0.3s ease !important;
}

...

#home:hover {
    padding-right: 10px;
}

关于html - 过渡不适用于任何属性(property)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26578923/

相关文章:

javascript - 如何更改 DataTables 中分页按钮的默认悬停样式

css - XML - 使用 xslt 样式表,没有给出输出

css - 如何使用 CSS 在悬停时添加不同的 CSS3 悬停过渡

Android: Activity 之间没有转换?

html - 低于一定宽度时调整 Bootstrap 4 网格的大小

javascript - URI 错误 : malformed URI sequence?

HTML 导航栏不居中,右侧有更多边距

html - 通过 css 在悬停时在渐变背景上显示图像

html - 当图像水平居中时,margin-top 不起作用 - Phonegap

c# - WPF 中的颜色过渡