简体   繁体   English

CSS3动画显示在2个属性上,而仅选择了1个

[英]CSS3 Animation is showed on 2 attributes while only 1 is selected

I have this code: 我有以下代码:

@keyframes margin-title
{
0% {margin: -170px 0 0 0}
100% {margin: -130px 0 0 0}
}

@-webkit-keyframes margin-title
{
0% {margin: -170px 0 0 0}
100% {margin: -130px 0 0 0}
}

h1 {
    margin: -130px 0 0 0;
    text-shadow: 0 0 10px #000;
    animation: margin-title 1s ease, fade-title 4s;
        -webkit-animation: margin-title 1s ease, fade-title 4s;
}

HTML: HTML:

 <div id="home">
<h1>Photal</h1>

<p>lorem ipsum</p>

</div>

The problem is that the animation " keyframe-title " is not only showed on the header, but the paragraph too, while I don't have used any CSS code for my paragraph. 问题是动画“ keyframe-title ”不仅显示在标题上,而且显示在段落上,尽管我没有为段落使用任何CSS代码。 They are both inside a div, that doesn't have any animation that could affect it (I guess). 它们都在div中,没有任何可能影响它的动画(我想)。

Here's a jsfiddle so you'll understand: http://jsfiddle.net/ad3gP/1/ 这是一个jsfiddle,您将了解: http : //jsfiddle.net/ad3gP/1/

Thank You 谢谢

Replace the end of your CSS file for this: 为此,请替换CSS文件的末尾:

    h1 {
    width: 440px;
    float: left;
    text-align:center;
    margin: -130px 0 0 0;
    color:#FFF;
    font-size:70px;
    font-family: 'Berkshire Swash', cursive;
    text-shadow: 0 0 10px #000;
    opacity:0.7;
        filter:Alpha(opacity=70);
    transition:opacity 0.5s;
        -webkit-transition:opacity 0.5s;
    animation: margin-title 1s ease, fade-title 4s;
        -webkit-animation: margin-title 1s ease, fade-title 4s;
}

h1:hover {
    opacity:0.9;
        filter:Alpha(opacity=90);
}

table {
    margin-top: -30px;
}

(added float: left; and width: 440px; to h1 and margin-top: -30px; to table ) (添加float: left; width: 440px;h1margin-top: -30px;table

The reason it didn't work is that the table starts underneath your title. 它不起作用的原因是表格在标题下方开始。 When the title moves down the table also moves down. 当标题向下移动时,表格也向下移动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM