Skip to content

Commit 1ace386

Browse files
committed
css的position定位
1 parent 672fad7 commit 1ace386

File tree

2 files changed

+59
-6
lines changed

2 files changed

+59
-6
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>position布局练习</title>
6+
<style type="text/css">
7+
h2.pos_left{
8+
position: relative;
9+
left: -20px;
10+
}
11+
h2.pos_right{
12+
position: relative;
13+
left: 50px;
14+
}
15+
16+
h2.pos_abs{
17+
position: absolute;
18+
left: 100px;
19+
top: 800px;
20+
}
21+
22+
p.one
23+
{
24+
position:fixed;
25+
left:5px;
26+
top:355px;
27+
}
28+
p.two
29+
{
30+
position:fixed;
31+
top:355px;
32+
right:5px;
33+
}
34+
</style>
35+
</head>
36+
<body>
37+
<div>
38+
<h2>relative这是正常位置的标题,相对定位会按照元素的原始位置对该元素进行移动。</h2>
39+
<h2 class="pos_left">relative这个标题相对于其他正常位置的偏移</h2>
40+
<h2 class="pos_right">relative这个标题相对于其他正常位置的偏移</h2>
41+
<hr>
42+
</div>
43+
<div>
44+
<h2 class="pos_abs">这是带有绝对定位的标题</h2>
45+
<p>通过绝对定位,元素可以放置到页面上的任何位置。下面的标题距离页面左侧 100px,距离页面顶部 150px。</p>
46+
<hr>
47+
</div>
48+
<div>
49+
<p class="one">一些文本。</p>
50+
<p class="two">更多的文本。</p>
51+
</div>
52+
</body>
53+
</html>

html&css练习/css练习之对齐.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
width: 300px;
2626
background-color: #b0e0e6;
2727
}
28-
.floatright{
29-
float: right;
30-
width: 300px;
31-
background-color: #b0e0e6;
28+
.floatleft{
29+
float: left;
30+
width: 400px;
31+
background-color: #bff0e6;
3232
}
3333
</style>
3434
</head>
@@ -44,8 +44,8 @@
4444
<p><b>注释:</b>当使用 position 属性进行对齐时,请始终包含 !DOCTYPE 声明!如果省略,则会在 IE 浏览器中产生奇怪的结果。</p>
4545
</div>
4646
</div>
47-
<div class="floatright">
48-
<p>这是一个段落,靠右对齐。是通过flaot:right实现</p>
47+
<div class="floatleft">
48+
<p>这是一个段落,靠左对齐。是通过flaot:left实现</p>
4949
</div>
5050
</body>
5151
</html>

0 commit comments

Comments
 (0)