File tree 2 files changed +59
-6
lines changed
2 files changed +59
-6
lines changed Original file line number Diff line number Diff line change
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 >
Original file line number Diff line number Diff line change 25
25
width : 300px ;
26
26
background-color : # b0e0e6 ;
27
27
}
28
- .floatright {
29
- float : right ;
30
- width : 300 px ;
31
- background-color : # b0e0e6 ;
28
+ .floatleft {
29
+ float : left ;
30
+ width : 400 px ;
31
+ background-color : # bff0e6 ;
32
32
}
33
33
</ style >
34
34
</ head >
44
44
< p > < b > 注释:</ b > 当使用 position 属性进行对齐时,请始终包含 !DOCTYPE 声明!如果省略,则会在 IE 浏览器中产生奇怪的结果。</ p >
45
45
</ div >
46
46
</ div >
47
- < div class ="floatright ">
48
- < p > 这是一个段落,靠右对齐 。是通过flaot:right实现 </ p >
47
+ < div class ="floatleft ">
48
+ < p > 这是一个段落,靠左对齐 。是通过flaot:left实现 </ p >
49
49
</ div >
50
50
</ body >
51
51
</ html >
You can’t perform that action at this time.
0 commit comments