top
或bottom
, left
或right
的CSS偏移告诉浏览器将项目相对于文档正常流程中的位置偏移多远。您将元素偏离给定的点,这会使元素远离引用的边(有效地,相反的方向)。正如您在上一次挑战中看到的那样,使用顶部偏移将h2
向下移动。同样,使用左偏移会将项目向右移动。 h2
移动15像素向右移动10像素。 tests: - text: 'Your code should use a CSS offset to relatively position the <code>h2</code> 10px upwards. In other words, move it 10px away from the <code>bottom</code> of where it normally sits.' testString: 'assert($("h2").css("bottom") == "10px", "Your code should use a CSS offset to relatively position the <code>h2</code> 10px upwards. In other words, move it 10px away from the <code>bottom</code> of where it normally sits.");' - text: 'Your code should use a CSS offset to relatively position the <code>h2</code> 15px towards the right. In other words, move it 15px away from the <code>left</code> of where it normally sits.' testString: 'assert($("h2").css("left") == "15px", "Your code should use a CSS offset to relatively position the <code>h2</code> 15px towards the right. In other words, move it 15px away from the <code>left</code> of where it normally sits.");'
<head> <style> h2 { position: relative; } </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>
// solution required
h2
移动15像素向右移动10像素。 h2
10px。换句话说,将它从通常所在位置的bottom
移开10px。
testString: 'assert($("h2").css("bottom") == "10px", "Your code should use a CSS offset to relatively position the h2
10px upwards. In other words, move it 10px away from the bottom
of where it normally sits.");'
- text: 您的代码应该使用CSS偏移来相对地将h2
15px定位到右侧。换句话说,将它从通常所在的位置left
移动15px。
testString: 'assert($("h2").css("left") == "15px", "Your code should use a CSS offset to relatively position the h2
15px towards the right. In other words, move it 15px away from the left
of where it normally sits.");'
```
I still think the h2 is where it normally sits.
```