1. Trang chủ
  2. » Giáo án - Bài giảng

tài liệu phần position

7 150 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 7
Dung lượng 61,62 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

position: static;... Các thuộc tính top, bottom, left and right không có tác dụng.. position: absolute; Ví dụ 1:... position: relativePosition:relative cho phép nó với div chứa nó gắn kế

Trang 1

1. position: static;

<div style="width:300px; height: 100px; border: 1px solid yellow;">

</div>

<div style="width:300px; height: 300px; border: 1px solid black;">

</div>

<div style="width:300px; height: 100px; border: 1px solid yellow;">

</div>

<div style="width:300px; height: 300px; border: 1px solid black;">

<div style="width:200px; height: 200px; border: 1px solid red; top: 100;ty” >

</div>

Trang 2

</div>

Các thuộc tính top, bottom, left and right không có tác dụng.

2 position: absolute;

Ví dụ 1:

<div style="width:300px; height: 100px; border: 1px solid yellow;">

</div>

Trang 3

5020

Trang 4

3 position: relative

Position:relative cho phép nó với div chứa nó gắn kết với nhau như sau:

Ví dụ 1:

<div style="width:300px; height: 100px; border: 1px solid yellow;">

</div>

<div style="width:300px; height: 300px; border: 1px solid black;">

<div style=" position: relative; top: 20px; left: 10px;width:200px; height: 200px;

border: 1px solid red;">

</div>

</div>

Top, left thì lấy từ góc trên, bên trái của div màu đen trở xuống dưới.

Trang 5

1020

Ví dụ 2:

<div style="width:300px; height: 100px; border: 1px solid yellow;">

</div>

<div style="width:300px; height: 300px; border: 1px solid black;">

<div style="position: relative; bottom: 20px; right: 10px; width:200px; height:

200px; border: 1px solid red;">

</div>

</div>

Trang 6

4 Kết hợp Position

<div style="width:300px; height: 100px; border: 1px solid yellow;">

</div>

<div style="position: relative; width:300px; height: 300px; border: 1px solid black;">

<div style=" position: absolute; top: 20px; left: 10px; width:200px; height: 200px;

border: 1px solid red;">

</div>

</div>

Khi thêm position:relative cho div màu đen và position:absolute cho div màu đỏ thì khung màu đỏ sẽ lấy div màu đen là góc, để định top,left,right,left tương ứng.

Trang 7

*Nếu cha relative hoặc absolute mà con là relative, absolute: Lấy cha làm gốc tọa độ.

Ngày đăng: 18/12/2014, 19:26

TỪ KHÓA LIÊN QUAN

w