【CSS】top - 要素の位置(上)
CSSのtopプロパティをご紹介します。
top
topは要素の上端の位置を示すプロパティです。
基本構文
top: 値;
サンプル
<style>
.container {
position: relative;
padding: 15px;
background: lightgray;
}
.box {
height: 100px;
background: yellow;
}
p {
margin: 0;
position: absolute;
top: 0;
}
</style>
<div class="container">
<div class="box"></div>
<hr>
<p>TEXT</p>
<div class="box"></div>
</div>