防止调整浏览器大小来更改HTML / CSS布局

对于CSS和HTML动画,我有以下代码:

index.html:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <title>Animation/LipstickAd</title>

  <link rel= "stylesheet" href = "style.css"></a>



  </head>
  <body>
  <div id="logos" class = "main1">
      <img src="moveable_part.png" height="750px" class="center"></img>
  </div>

  <div class="main">
          <img id="lipstick_ad" src="lipstick_ad.png" height="750px" class="center"></img>
  </div>
</body>
</html>

style.css具有以下位置:


#logos{
  position: relative;
  -webkit-animation: mymove 2s infinite;

}

    @-webkit-keyframes mymove {

      0%{
        top:80px;
        opacity:0%;
        /* -webkit-animation-timing-function: ease-in; */

      }

      50%{
        opacity:100%;
        top:50px;
        /* -webkit-animation-timing-function: ease-out; */
      }

      100%{
        top:80px;
      }


    }


    .center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.main1 {
  position: fixed;
  top: 80px;
  right: -285px;
  width: 200px;
  height: 100px;
}

这在全屏模式下效果很好(我通过反复试验发现了正确的px),但是一旦我调整浏览器的大小,main1中元素的位置(口红顶部就会改变)及其看起来很糟糕。

如何防止这种情况?

谢谢!

andys740813 回答:防止调整浏览器大小来更改HTML / CSS布局

Metatag视口的目的是在网页上获得响应,要防止在调整大小时默认响应,只需将其删除即可。
在HTML下方使用,或从代码中删除视口元行

opensource system
本文链接:https://www.f2er.com/3062654.html

大家都在问