move a relatively positioned element with css offsets - zilongxuan001/LearnFreecode GitHub Wiki
CSS偏移的top
,botton
,left
,right
,是告诉浏览器条目相对原来的文档自然流偏移多少。
你可以偏移元素从一个给定的点,移动元素到指向的边(通常是相反的方向)。正如你在最后一个挑战里看到的,使用top
偏移h2
往下。同样,使用左偏移就是把一个条目移到右边。
使用CSS偏移,移动h2
到右边15px,到上方10px。
<head>
<style>
h2 {
position: relative;
left: 15px;
bottom: 10px;
}
</style>
</head>
<body>
<h1>On Being Well-Positioned</h1>
<h2>Move me!</h2>
<p>I still think the h2 is where it normally sits.</p>
</body>
Applied Visual Design: Move a Relatively Positioned Element with CSS Offsets | Learn freeCodeCamp
2018-10-23 16:28:27