English 中文(简体)
为什么我在上页后第一次点击纽子时,没有妥善工作,而是在第一次点击之后正确工作?
原标题:Why does my flip card animation not work properly on the first click of the button after the page loads, but works correctly after that first click?

目前,我正在利用超文本、CSS和Javales对我的项目进行脂重心分析。 当“More”纽顿被点击和卡片外壳暴露后方时,按预期的算法。 同样,点击“Back” but子将卡片回原来的状态。

然而,我正面临一个问题,即点燃在页数后第一个点点“More”纽顿时不会顺利进行。 它是部分的,未产生3效应。 随后点击了工作罚款,并以适当方式引发 an。

我将我的超文本、中文本安全局和 Java文本列入以下参考:

<div id="meal-card" class="card">
                        <div id="meal-card-front" class="card-front">
                            <div class="inline">
                                <h3 id="meal-name"></h3>
                                <p id="btn-container"><a id="btn-see-more" href="#<strong>More</strong></a></p>
                            </div>
                            <div><img id="meal-image" src=""></div>
                            <h4>Ingredients</h4>
                            <p id="ingredients"></p>
                        </div>
                        <div id="meal-card-back" class="card-back">
                            <div class="inline">
                                <h4>Instructions</h4>
                                <p id="btn-get-back"><a href="#"><strong>Back</strong></a></p>
                            </div>
                            <p id="instructions"></p>
                        </div>
.card {
    perspective: 1000px;
}


.card-front, .card-back{
    background: #fffcec;
    border-radius: 5px;
    text-align: center;
    width: 480px;
    height: 470px;
    padding: 0;
    box-shadow: 4px 4px 9px rgba(0, 0, 0, 0.2);
    position: absolute;
    backface-visibility: hidden;
    transition: transform 0.6s;
}
  
.card-back {
    transform: rotateY(180deg);
}
  
/* This class is added to the card when it should flip */
.flipped .card-front{
    transform: rotateY(180deg);
}
  
.flipped .card-back {
    transform: rotateY(0deg);
}
var moreBtn = document.getElementById("btn-see-more");
var backBtn = document.getElementById("btn-get-back");

moreBtn.addEventListener("click", function(){
    mealCard.classList.add("flipped");
    $("#meal-card-back").show();
});

backBtn.addEventListener("click", function(){
    mealCard.classList.remove("flipped");
});

是否有任何人能够就如何确保纸张消im工作顺利进行提出见解或建议,哪怕是在上页后首点击?

任何帮助或指导都将受到高度赞赏。 谢谢!

问题回答

由于你没有将<代码>mealCard列入贵国法律汇编,因此无法确定该编码是什么。 我只是试图添加这一条线,并在你的超文本上做一些定点,因为一些标签和报价缺失。 这对我来说似乎很不错。

    var mealCard = document.getElementById( meal-card );

var moreBtn = document.getElementById( btn-see-more );
var backBtn = document.getElementById( btn-get-back );
var mealCard = document.getElementById( meal-card );

moreBtn.addEventListener( click , function() {
  mealCard.classList.add( flipped );
});

backBtn.addEventListener( click , function() {
  mealCard.classList.remove( flipped );
});
.card {
  perspective: 1000px;
}

.card-front,
.card-back {
  background: #fffcec;
  border-radius: 5px;
  text-align: center;
  width: 480px;
  height: 470px;
  padding: 0;
  box-shadow: 4px 4px 9px rgba(0, 0, 0, 0.2);
  position: absolute;
  backface-visibility: hidden;
  transition: transform 0.6s;
}

.card-back {
  transform: rotateY(180deg);
}


/* This class is added to the card when it should flip */

.flipped .card-front {
  transform: rotateY(180deg);
}

.flipped .card-back {
  transform: rotateY(0deg);
}
<!DOCTYPE html>
<html lang="en">

<head>
  <title>Home</title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width" />
  <!--
      Need a visual blank slate?
      Remove all code in `styles.css`!
    -->
  <link rel="stylesheet" href="styles.css" />
  <script type="module" src="script.js"></script>
</head>

<body>
  <div id="meal-card" class="card">
    <div id="meal-card-front" class="card-front">
      <div class="inline">
        <h3 id="meal-name"></h3>
        <p id="btn-container">
          <a id="btn-see-more" href="#">
            <strong>More</strong>
          </a>
        </p>
      </div>
      <div>
        <img id=" meal-image " src=" " />
      </div>
      <h4>Ingredients</h4>
      <p id="ingredients "></p>
    </div>
    <div id="meal-card-back" class="card-back">
      <div class="inline">
        <h4>Instructions</h4>
        <p id="btn-get-back">
          <a href="# ">
            <strong>Back</strong>
          </a>
        </p>
      </div>
      <p id="instructions "></p>
    </div>
  </div>
</body>

</html>

Btw I guess this line is redundant since #meal-card-back is already shown?

    $("#meal-card-back").show();




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签