2.0 KiB
2.0 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d78a3367417b2b2512ace | Push Elements Left or Right with the float Property | 0 | 使用float属性向左或向右推送元素 |
Description
position
,而是设置元素的float
属性。浮动元素从文档的正常流中移除,并推送到其包含的父元素的left
或right
。它通常与width
属性一起使用,以指定浮动元素需要多少水平空间。 Instructions
section
和aside
元素彼此相邻。给#left
项float
的left
和#right
项float
的right
。 Tests
tests:
- text: id为<code>left</code>的元素的<code>float</code>值应为<code>left</code> 。
testString: 'assert($("#left").css("float") == "left", "The element with id <code>left</code> should have a <code>float</code> value of <code>left</code>.");'
- text: id为<code>right</code>的元素的<code>float</code>值应为<code>right</code> 。
testString: 'assert($("#right").css("float") == "right", "The element with id <code>right</code> should have a <code>float</code> value of <code>right</code>.");'
Challenge Seed
<head>
<style>
#left {
width: 50%;
}
#right {
width: 40%;
}
aside, section {
padding: 2px;
background-color: #ccc;
}
</style>
</head>
<body>
<header>
<h1>Welcome!</h1>
</header>
<section id="left">
<h2>Content</h2>
<p>Good stuff</p>
</section>
<aside id="right">
<h2>Sidebar</h2>
<p>Links</p>
</aside>
</body>
Solution
// solution required