按钮堆叠在一起?
问题描述:
进出口创造了德国一个网站,并有对方如家堆的按钮当我把它设置到位置问题:绝对的或固定的。但是,当我把它设置为相对的,它的作品。有人能解释我吗?按钮堆叠在一起?
CSS文件:
#top {
display: inline-block;
width: 352px;
height: 160px;
color : white;
background-color: #2D2D2D;
float: left;
font-family: century gothic;
font-size: 25px;
border: none;
margin: 0px;
position: fixed
}
和HTML文件:
<nav>
<a class="weiter" href="Home.html"><button id="top" >Home</button></a>
<a class="weiter" href="ueberuns.html">
<button id="top">Überuns</button></a>
<a class="weiter"><button id="top" id="click">Mitglieder</button></a>
<a class="weiter" href="gebiet.html"><button
id="top">UnserGebiet</button></a>
<a class="weiter" href="kontakt.html"><button id="top">Kontakt</button></a>
</nav>
答
- 它与
position: absolute|fixed
一个预期的行为。 - 这些定位让您放置在那里你到底希望它是按钮更精细的控制。
- 您可以使用
top
left
right
和bottom
为您提供确切的像素完美定位。
进一步阅读:https://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/
答
绝对位置并固定两者使用DOM作为参考例如在屏幕的左上角和作为用于显示的最高优先级处理。因此您分配的最后一个“*”课程将位于顶部。如果您为其中一个按钮指定另一个ID并使用定向CSS指令:
#Bottom{right:100px;}
您将看到div开始移开。
因此,在总结固定和绝对的治疗分配的所有项目作为重中之重的HTML的顺序,并将其移动到屏幕的左上角。
+0
感谢您的意见,我意识到这一点! – GoS
能否请您为我们提供了两种结果的截图? – Aenadon