乐趣区

fe6-2:CSS部分

一、元素定位 (position):static、relative、absolute、fixed 其中,static 是默认定位;relative 是相对定位;absolute 是完全绝对定位,忽略其他所有东西,往上浮动到 非 static 的元素;fixed 基于 window 的绝对定位, 不随页面滚动改变
//relative
.square {
color: black;
position: relative;
top: -12px;
}
<h1 class=”green”>E = MC<span class=”square”>2</span> 质能公式 </h1>

//absolute
.close {
position: absolute;
top: 0px;
right: 0px;
}
<button class=”close”>X</button>

//fixed
.fixed {
background: black;
color: white;
position: fixed;
top: 0px;
left: 0px;
}
<button class=”fixed”>fixed 按钮 </button>

退出移动版