tailieunhanh - Học JavaScript qua ví dụ part 68

Sở hữu className Các tài sản className được sử dụng để tham khảo một lớp CSS. Các tài sản className được định nghĩa cho tất cả các phần tử HTML. Với tài sản className, bạn có thể thay đổi một phần tử tự động bằng cách chỉ định nó là tên của một lớp được định nghĩa trong CSS. | 598 Chapter 14 Introduction to CSS Cascading Style Sheets with JavaScript EXPLANATION 3 If the zIndex of the object evaluates to 100 it must be at the top of the stack because that is as high as the stack gets. 4 This sets the stack level of the zIndex to 2 causing it to move toward the bottom of the stack. 5 If the zIndex for the object is not 3 it is not at the top. Its zIndex will be set to 100 moving it to the top of the stack. 6 The object is moved to the bottom of the stack with a zIndex of 0. 7 The span tag is used to create a rectangular red box on the screen. With a zIndex of 0 it will be positioned at the bottom of the stack. 8 When the user clicks the button the onClick event is triggered and the handler function moveUp id is called. 9 A yellow rectangular box is created with the span tag. With a zIndex of 1 it will be positioned above the last block in the stack. 10 A blue square box is created with the span tag. With a zIndex of 2 it will be positioned above the last block in the stack. 11 A small white rectangular box is created with the span tag. With a zIndex of 3 it will be positioned at the top of the stack. See Figure . Figure The original configuration of the four rectangles left after manipulating the rectangles by reassigning the z-index right . The className Property The className property is used to reference a CSS class. The className property is defined for all HTML elements. With the className property you can change an element dynamically by assigning it the name of a class defined in a CSS. Example contains a CSS with three classes. From the Library of Where Does JavaScript Fit In 599 EXAMPLE html head title Coloring Text title style type text css body background-color yellow font-size 22pt font-weight bold 1 .red color rgb 255 0 0 Defining classes font-style verdana font-size 32 2 .blue color blue font-style verdana font-size 36 3 .green color green font-style verdana font-size 40 style

TỪ KHÓA LIÊN QUAN