CSS元素移动

huangapple go评论70阅读模式
英文:

CSS element moving

问题

你好,我从开始进行网页开发以来就一直遇到这个问题。当我放大页面时,容器也会移动。有没有办法解决这个问题?

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->
.darkslidecont{
    width: 200px;
    height: 50px;
    position: relative;
    background-color: white;
    left: 80%;
    display: block;
    flex-wrap: flex;
}

<!-- language: lang-html -->
<header>
    <h1 id="welcomeText"><u>Welcome to My Portfolio!</u></h1>
    <div class="darkslidecont">
    </div>
</header>

<!-- end snippet -->

我已经尝试过更改位置和显示属性,但没有成功。

英文:

Hello I have had this issue since the beginning of my web development start. When I zoom in the container moves in too. any way i can solve this?

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.darkslidecont{
    width: 200px;
    height: 50px;
    position: relative;
    background-color: white;
    left: 80%;
    display: block;
    flex-wrap: flex;
}

<!-- language: lang-html -->

&lt;header&gt;
    &lt;h1 id=&quot;welcomeText&quot;&gt;&lt;u&gt;Welcome to My Portfolio!&lt;/u&gt;&lt;/h1&gt;
    &lt;div class=&quot;darkslidecont&quot;&gt;
    &lt;/div&gt;
&lt;/header&gt;

<!-- end snippet -->

I have played around with the positions and display but no luck

答案1

得分: 0

重置 CSS

* {
  margin: 0;
  padding: 0;
}

.darkslidecont {
  width: 200px;
  height: 50px;
  position: relative;
  background-color: white;
  left: 80%;
  display: block;
  flex-wrap: flex;
}
<header>
  <h1 id="welcomeText"><u>Welcome to My Portfolio!</u></h1>
  <div class="darkslidecont">
  </div>
</header>
英文:

Reset css

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

* {
  margin: 0;
  padding: 0;
}

.darkslidecont{
    width: 200px;
    height: 50px;
    position: relative;
    background-color: white;
    left: 80%;
    display: block;
    flex-wrap: flex;
}

<!-- language: lang-html -->

&lt;header&gt;
    &lt;h1 id=&quot;welcomeText&quot;&gt;&lt;u&gt;Welcome to My Portfolio!&lt;/u&gt;&lt;/h1&gt;
    &lt;div class=&quot;darkslidecont&quot;&gt;
    &lt;/div&gt;
&lt;/header&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年8月9日 08:22:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76863846.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定