1e41f4b71Sopenharmony_ci# div
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci>  **NOTE**
4e41f4b71Sopenharmony_ci>
5e41f4b71Sopenharmony_ci>  This component is supported since API version 4. Updates will be marked with a superscript to indicate their earliest API version.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciThe **\<div>** component is a basic container that is used as the root node of the page structure or is used to group the content.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci## Required Permissions
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciNone
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci## Child Components
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ciSupported
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci## Attributes
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciThe [universal attributes](js-components-common-attributes.md) are supported.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci## Styles
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ciIn addition to the [universal styles](js-components-common-styles.md), the following styles are supported.
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci| Name                          | Type          | Default Value      | Mandatory| Description                                                        |
29e41f4b71Sopenharmony_ci| ------------------------------ | -------------- | ------------ | ---- | ------------------------------------------------------------ |
30e41f4b71Sopenharmony_ci| flex-direction                 | string         | row          | No  | Main axis direction of the flex container, which defines how items are placed in the container. Available values are as follows:<br>- **column**: Items are placed vertically from top to bottom.<br>- **row**: Items are placed horizontally from left to right.|
31e41f4b71Sopenharmony_ci| flex-wrap                      | string         | nowrap       | No  | Whether items in the flex container are displayed in a single line or multiple lines. The value cannot be dynamically updated. Available values are as follows:<br>- **nowrap**: Flex items are displayed in a single line.<br>- **wrap**: Flex items are displayed in multiple lines.|
32e41f4b71Sopenharmony_ci| justify-content                | string         | flex-start   | No  | How items are aligned along the main axis of the flex container. Available values are as follows:<br>- **flex-start**: Items are packed toward the start edge of the container along the main axis.<br>- **flex-end**: Items are packed toward the end edge of the container along the main axis.<br>- **center**: Items are packed toward the center of the container along the main axis.<br>- **space-between**: Items are positioned with space between the rows.<br>- **space-around**: Items are positioned with space before, between, and after the rows.<br>- **space-evenly**<sup>5+</sup>: Items are distributed within the container along the main axis, with even space between each two.|
33e41f4b71Sopenharmony_ci| align-items                    | string         | stretch<br>| No  | How items are aligned along the cross axis in a flex container. Available values are as follows:<br>- **stretch**: Items are stretched to the same height or width as the container along the cross axis.<br>- **flex-start**: Items are packed toward the start edge of the cross axis.<br>- **flex-end**: Items are packed toward the end edge of the cross axis.<br>- **center**: Items are packed toward the center of the cross axis.<br>- **baseline**: In a vertical layout, items are aligned to the start of the cross axis, which means that this value is equivalent of **flex-start**. In a horizontal layout, items are aligned with the text baseline if there is text involved, and aligned to the bottom otherwise.|
34e41f4b71Sopenharmony_ci| align-content                  | string         | flex-start   | No  | Multi-row alignment mode when there is extra space in the cross axis. Available values are as follows:<br>- **flex-start**: All rows are packed toward the start edge of the cross axis. The start edge of the cross axis of the first row is aligned with the start edge of the cross axis of the container. All subsequent rows are aligned with the previous row.<br>- **flex-end**: All rows are packed toward the end edge of the cross axis. The end of the cross axis of the last row is aligned with the end of the cross axis of the container. All subsequent rows are aligned with the previous row.<br>- **center**: All rows are packed toward the center of the cross axis. Rows are close to each other and aligned with the center of the container. The spacing between the start edge of the container's cross axis and the first row is equal to the spacing between the end edge of the container's cross axis and the last row.<br>- **space-between**: All rows are evenly distributed in the container. The spacing between two adjacent rows is the same. The start and end edges of the container's cross axis are aligned with the edges of the first and last rows, respectively.<br>- **space-around**: All rows are evenly distributed in the container. The spacing between two adjacent rows is the same. The spacing between the start edge of the container's cross axis and the first row and that between the end edge and the last row are half of the spacing between two adjacent rows.|
35e41f4b71Sopenharmony_ci| grid-template-[columns\|rows]  | string         | 1 row, 1 column      | No  | Number of rows and columns in the current grid layout. If this attribute is not set, one row and one column are displayed by default. This attribute is valid only when **display** is set to **grid**.<br>Below are some example values of **grid-template-columns**:<br>- **50px 100px 60px**: There are three columns. The first column is 50 px, the second column is 100 px, and the third column is 60 px.<br>- **1fr 1fr 2fr**: There are three columns, and the width allowed by the parent component is divided into four equal shares. The first column occupies one share, the second column occupies one share, and the third column occupies two shares.<br>- **30% 20% 50%**: There are three columns. The first column occupies 30% of the total width allowed by the parent component, the second column occupies 20%, and the third column occupies 50%.<br>- **repeat (2,100px)**: There are two columns. The first column is 100 px, and the second column is 100 px.<br>- **repeat(auto-fill,100px)**<sup>5+</sup>: Each column is 100 px and repeats to fill the cross axis. The number of columns is calculated based on the column size and the cross axis size.<br>- **auto 1fr 1fr**: There are three columns. The first column is adaptive to the width required by its child components. The remaining space is divided into two equal shares, one share occupied by each of the rest two columns.|
36e41f4b71Sopenharmony_ci| grid-[columns\|rows]-gap       | &lt;length&gt; | 0            | No  | Size of the gap between two consecutive rows or columns in a grid layout. You can also use **grid-gap** to set the same size of the gap between rows and columns. This attribute is valid only when **display** is set to **grid**.|
37e41f4b71Sopenharmony_ci| grid-row-[start\|end]          | number         | -            | No  | Start and end row numbers of the current item in the grid layout. This attribute is valid only when the item's parent component is a **\<div>** container whose **display** style is set to **grid**.|
38e41f4b71Sopenharmony_ci| grid-column-[start\|end]       | number         | -            | No  | Start and end column numbers of the current item in the grid layout. This attribute is valid only when the item's parent component is a **\<div>** container whose **display** style is set to **grid**.|
39e41f4b71Sopenharmony_ci| grid-auto-flow<sup>5+</sup>    | string         | -            | No  | How grid items are laid out automatically. Available values are as follows:<br>- **row**: Elements are filled row by row. When there is no horizontal space in a row, a new row is added.<br>- **column**: Elements are filled column by column. When there is no vertical space in a column, a new column is added.|
40e41f4b71Sopenharmony_ci| overflow<sup>6+</sup>          | string         | visible      | No  | Display mode when the content exceeds the container size. Available values are as follows:<br>- **visible**: Displays the excess content outside the container.<br>- **hidden**: Truncates the excess content.<br>- **scroll**: Scrolls the content vertically, with a scrollbar provided.<br>**scroll** works for elements whose size is fixed. By default, the scrolling direction is the same as the container direction.|
41e41f4b71Sopenharmony_ci| align-items<sup>6+</sup>       | string         | -            | No  | How items are aligned along the cross axis in a flex container. Available values are as follows:<br>- **stretch**: Items are stretched to the same height or width as the flex container along the cross axis.<br>- **flex-start**: Items are aligned to the start of the cross axis.<br>- **flex-end**: Items are aligned to the end of the cross axis.<br>- **center**: Items are aligned in the center of the cross axis.<br>- **baseline**: In a vertical layout, items are aligned to the start of the cross axis, which means that this value is equivalent of **flex-start**. In a horizontal layout, items are aligned with the text baseline if there is text involved, and aligned to the bottom otherwise.|
42e41f4b71Sopenharmony_ci| scrollbar-color<sup>6+</sup>   | &lt;color&gt;  | -            | No  | Color of the scrollbar.                                          |
43e41f4b71Sopenharmony_ci| scrollbar-width<sup>6+</sup>   | &lt;length&gt; | -            | No  | Width of the scrollbar.                                          |
44e41f4b71Sopenharmony_ci| overscroll-effect<sup>6+</sup> | string         | -            | No  | How the scrollbar behaves when it reaches the edge of the scrolling area. Available values are as follows:<br>- **spring**: Similar to the physical dynamic effect of a spring. When the scrollbar reaches the edge, it can continue to scroll for a distance based on the initial speed or a touch event. It rebounds after being released.<br>- **fade**: Similar to the physical dynamic effect of fade. When the scrollbar reaches the edge, a wave shape fades. The fade changes according to the speed and scrolling distance.<br>- **none**: No effect when the scrollbar reaches the edge.|
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci## Events
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ciIn addition to the [universal events](js-components-common-events.md), the following events are supported.
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci| Name                      | Parameter  | Description                                      |
54e41f4b71Sopenharmony_ci| ------------------------ | ---- | ---------------------------------------- |
55e41f4b71Sopenharmony_ci| reachstart<sup>6+</sup>  | -    | Triggered when the page scrolls to the beginning. This event is triggered only when **flex-direction** is **row**.|
56e41f4b71Sopenharmony_ci| reachend<sup>6+</sup>    | -    | Triggered when the page scrolls to the end. This event is triggered only when **flex-direction** is **row**.|
57e41f4b71Sopenharmony_ci| reachtop<sup>6+</sup>    | -    | Triggered when the page scrolls to the top. This event is triggered only when **flex-direction** is **column**.|
58e41f4b71Sopenharmony_ci| reachbottom<sup>6+</sup> | -    | Triggered when the page scrolls to the bottom. This event is triggered only when **flex-direction** is **column**.|
59e41f4b71Sopenharmony_ci
60e41f4b71Sopenharmony_ci## Methods
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ciIn addition to the [universal methods](js-components-common-methods.md), the following methods are supported.
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci| Name                          | Parameter         | Return Value         | Description                                     |
65e41f4b71Sopenharmony_ci| ---------------------------- | ----------- | ------------ | --------------------------------------- |
66e41f4b71Sopenharmony_ci| getScrollOffset<sup>6+</sup> | -           | ScrollOffset | Obtains the scrolling offset of the element content.<br>To use this method, **overflow** must be set to **scroll**.|
67e41f4b71Sopenharmony_ci| scrollBy<sup>6+</sup>        | ScrollParam | -            | Sets the scrolling offset of the element content.<br>To use this method, **overflow** must be set to **scroll**.|
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci**Table 1** ScrollOffset<sup>6+</sup>
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci| Name  | Type    | Description             |
72e41f4b71Sopenharmony_ci| ---- | ------ | --------------- |
73e41f4b71Sopenharmony_ci| x    | number | Offset in the x-axis direction, in px.|
74e41f4b71Sopenharmony_ci| y    | number | Offset in the y-axis direction, in px.|
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci**Table 2** ScrollParam<sup>6+</sup>
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci| Name    | Type     | Description              |
79e41f4b71Sopenharmony_ci| ------ | ------- | ---------------- |
80e41f4b71Sopenharmony_ci| dx     | number  | Offset for scrolling in the horizontal direction, in px.|
81e41f4b71Sopenharmony_ci| dy     | number  | Offset for scrolling in the vertical direction, in px.|
82e41f4b71Sopenharmony_ci| smooth | boolean | Whether to perform smooth processing.         |
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci## Example
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci1. Flex style
88e41f4b71Sopenharmony_ci   ```html
89e41f4b71Sopenharmony_ci   <!-- xxx.hml -->
90e41f4b71Sopenharmony_ci   <div class="container">
91e41f4b71Sopenharmony_ci     <div class="flex-box">
92e41f4b71Sopenharmony_ci       <div class="flex-item color-primary"></div>
93e41f4b71Sopenharmony_ci       <div class="flex-item color-warning"></div>
94e41f4b71Sopenharmony_ci       <div class="flex-item color-success"></div>
95e41f4b71Sopenharmony_ci     </div>
96e41f4b71Sopenharmony_ci   </div>
97e41f4b71Sopenharmony_ci   ```
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci   ```css
100e41f4b71Sopenharmony_ci   /* xxx.css */
101e41f4b71Sopenharmony_ci   .container {
102e41f4b71Sopenharmony_ci     flex-direction: column;
103e41f4b71Sopenharmony_ci     justify-content: center;
104e41f4b71Sopenharmony_ci     align-items: center;
105e41f4b71Sopenharmony_ci     width: 454px;
106e41f4b71Sopenharmony_ci     height: 454px;
107e41f4b71Sopenharmony_ci   }
108e41f4b71Sopenharmony_ci   .flex-box {
109e41f4b71Sopenharmony_ci     justify-content: space-around;
110e41f4b71Sopenharmony_ci     align-items: center;
111e41f4b71Sopenharmony_ci     width: 400px;
112e41f4b71Sopenharmony_ci     height: 140px;
113e41f4b71Sopenharmony_ci     background-color: #ffffff;
114e41f4b71Sopenharmony_ci   }
115e41f4b71Sopenharmony_ci   .flex-item {
116e41f4b71Sopenharmony_ci     width: 120px;
117e41f4b71Sopenharmony_ci     height: 120px;
118e41f4b71Sopenharmony_ci     border-radius: 16px;
119e41f4b71Sopenharmony_ci   }
120e41f4b71Sopenharmony_ci   .color-primary {
121e41f4b71Sopenharmony_ci     background-color: #007dff;
122e41f4b71Sopenharmony_ci   }
123e41f4b71Sopenharmony_ci   .color-warning {
124e41f4b71Sopenharmony_ci     background-color: #ff7500;
125e41f4b71Sopenharmony_ci   }
126e41f4b71Sopenharmony_ci   .color-success {
127e41f4b71Sopenharmony_ci     background-color: #41ba41;
128e41f4b71Sopenharmony_ci   }
129e41f4b71Sopenharmony_ci   ```
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci   ![en-us_image_0000001127285076](figures/en-us_image_0000001127285076.png)
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci2. Flex wrap style
134e41f4b71Sopenharmony_ci   ```html
135e41f4b71Sopenharmony_ci   <!-- xxx.hml -->
136e41f4b71Sopenharmony_ci   <div class="container">
137e41f4b71Sopenharmony_ci     <div class="flex-box">
138e41f4b71Sopenharmony_ci       <div class="flex-item color-primary"></div>
139e41f4b71Sopenharmony_ci       <div class="flex-item color-warning"></div>
140e41f4b71Sopenharmony_ci       <div class="flex-item color-success"></div>
141e41f4b71Sopenharmony_ci     </div>
142e41f4b71Sopenharmony_ci   </div>
143e41f4b71Sopenharmony_ci   ```
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci   ```css
146e41f4b71Sopenharmony_ci   /* xxx.css */
147e41f4b71Sopenharmony_ci   .container {
148e41f4b71Sopenharmony_ci     flex-direction: column;
149e41f4b71Sopenharmony_ci     justify-content: center;
150e41f4b71Sopenharmony_ci     align-items: center;
151e41f4b71Sopenharmony_ci     width: 454px;
152e41f4b71Sopenharmony_ci     height: 454px;
153e41f4b71Sopenharmony_ci   }
154e41f4b71Sopenharmony_ci   .flex-box {
155e41f4b71Sopenharmony_ci     justify-content: space-around;
156e41f4b71Sopenharmony_ci     align-items: center;
157e41f4b71Sopenharmony_ci     flex-wrap: wrap;
158e41f4b71Sopenharmony_ci     width: 300px;
159e41f4b71Sopenharmony_ci     height: 250px;
160e41f4b71Sopenharmony_ci     background-color: #ffffff;
161e41f4b71Sopenharmony_ci   }
162e41f4b71Sopenharmony_ci   .flex-item {
163e41f4b71Sopenharmony_ci     width: 120px;
164e41f4b71Sopenharmony_ci     height: 120px;
165e41f4b71Sopenharmony_ci     border-radius: 16px;
166e41f4b71Sopenharmony_ci   }
167e41f4b71Sopenharmony_ci   .color-primary {
168e41f4b71Sopenharmony_ci     background-color: #007dff;
169e41f4b71Sopenharmony_ci   }
170e41f4b71Sopenharmony_ci   .color-warning {
171e41f4b71Sopenharmony_ci     background-color: #ff7500;
172e41f4b71Sopenharmony_ci   }
173e41f4b71Sopenharmony_ci   .color-success {
174e41f4b71Sopenharmony_ci     background-color: #41ba41;
175e41f4b71Sopenharmony_ci   }
176e41f4b71Sopenharmony_ci   ```
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci   ![22](figures/22.png)
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci3. Grid style
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ci   ```html
183e41f4b71Sopenharmony_ci   <!-- xxx.hml -->
184e41f4b71Sopenharmony_ci   <div class="common grid-parent">
185e41f4b71Sopenharmony_ci     <div class="grid-child grid-left-top"></div>
186e41f4b71Sopenharmony_ci     <div class="grid-child grid-left-bottom"></div>
187e41f4b71Sopenharmony_ci     <div class="grid-child grid-right-top"></div>
188e41f4b71Sopenharmony_ci     <div class="grid-child grid-right-bottom"></div>
189e41f4b71Sopenharmony_ci   </div>
190e41f4b71Sopenharmony_ci   ```
191e41f4b71Sopenharmony_ci
192e41f4b71Sopenharmony_ci   ```css
193e41f4b71Sopenharmony_ci   /* xxx.css */
194e41f4b71Sopenharmony_ci   .common {
195e41f4b71Sopenharmony_ci     width: 400px;
196e41f4b71Sopenharmony_ci     height: 400px;
197e41f4b71Sopenharmony_ci     background-color: #ffffff;
198e41f4b71Sopenharmony_ci     align-items: center;
199e41f4b71Sopenharmony_ci     justify-content: center;
200e41f4b71Sopenharmony_ci     margin: 24px;
201e41f4b71Sopenharmony_ci   }
202e41f4b71Sopenharmony_ci   .grid-parent {
203e41f4b71Sopenharmony_ci     display: grid;
204e41f4b71Sopenharmony_ci     grid-template-columns: 35% 35%;
205e41f4b71Sopenharmony_ci     grid-columns-gap: 24px;
206e41f4b71Sopenharmony_ci     grid-rows-gap: 24px;
207e41f4b71Sopenharmony_ci     grid-template-rows: 35% 35%;
208e41f4b71Sopenharmony_ci   }
209e41f4b71Sopenharmony_ci   .grid-child {
210e41f4b71Sopenharmony_ci     width: 100%;
211e41f4b71Sopenharmony_ci     height: 100%;
212e41f4b71Sopenharmony_ci     border-radius: 8px;
213e41f4b71Sopenharmony_ci   }
214e41f4b71Sopenharmony_ci   .grid-left-top {
215e41f4b71Sopenharmony_ci     grid-row-start: 0;
216e41f4b71Sopenharmony_ci     grid-column-start: 0;
217e41f4b71Sopenharmony_ci     grid-row-end: 0;
218e41f4b71Sopenharmony_ci     grid-column-end: 0;
219e41f4b71Sopenharmony_ci     background-color: #3f56ea;
220e41f4b71Sopenharmony_ci   }
221e41f4b71Sopenharmony_ci   .grid-left-bottom {
222e41f4b71Sopenharmony_ci     grid-row-start: 1;
223e41f4b71Sopenharmony_ci     grid-column-start: 0;
224e41f4b71Sopenharmony_ci     grid-row-end: 1;
225e41f4b71Sopenharmony_ci     grid-column-end: 0;
226e41f4b71Sopenharmony_ci     background-color: #00aaee;
227e41f4b71Sopenharmony_ci   }
228e41f4b71Sopenharmony_ci   .grid-right-top {
229e41f4b71Sopenharmony_ci     grid-row-start: 0;
230e41f4b71Sopenharmony_ci     grid-column-start: 1;
231e41f4b71Sopenharmony_ci     grid-row-end: 0;
232e41f4b71Sopenharmony_ci     grid-column-end: 1;
233e41f4b71Sopenharmony_ci     background-color: #00bfc9;
234e41f4b71Sopenharmony_ci   }
235e41f4b71Sopenharmony_ci   .grid-right-bottom {
236e41f4b71Sopenharmony_ci     grid-row-start: 1;
237e41f4b71Sopenharmony_ci     grid-column-start: 1;
238e41f4b71Sopenharmony_ci     grid-row-end: 1;
239e41f4b71Sopenharmony_ci     grid-column-end: 1;
240e41f4b71Sopenharmony_ci     background-color: #47cc47;
241e41f4b71Sopenharmony_ci   }
242e41f4b71Sopenharmony_ci   ```
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ci   ![11](figures/11.png)
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci4. Dragging<sup>7+</sup>
247e41f4b71Sopenharmony_ci   ```html
248e41f4b71Sopenharmony_ci   <!-- xxx.hml -->
249e41f4b71Sopenharmony_ci   <div class="container">
250e41f4b71Sopenharmony_ci     <div class="content" ondragstart="dragstart" ondrag="drag" ondragend="dragend" style="position: absolute;left: {{left}};top: {{top}};">
251e41f4b71Sopenharmony_ci     </div>
252e41f4b71Sopenharmony_ci   </div>
253e41f4b71Sopenharmony_ci   ```
254e41f4b71Sopenharmony_ci
255e41f4b71Sopenharmony_ci   ```css
256e41f4b71Sopenharmony_ci    /* xxx.css */
257e41f4b71Sopenharmony_ci    .container {
258e41f4b71Sopenharmony_ci    flex-direction: column;
259e41f4b71Sopenharmony_ci    width: 100%;
260e41f4b71Sopenharmony_ci    height: 100%;
261e41f4b71Sopenharmony_ci    }
262e41f4b71Sopenharmony_ci    .content {
263e41f4b71Sopenharmony_ci    width: 200px;
264e41f4b71Sopenharmony_ci    height: 200px;
265e41f4b71Sopenharmony_ci    background-color: red;
266e41f4b71Sopenharmony_ci    }
267e41f4b71Sopenharmony_ci   ```
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ci   ```js
270e41f4b71Sopenharmony_ci   // xxx.js
271e41f4b71Sopenharmony_ci   import promptAction from '@ohos.promptAction';
272e41f4b71Sopenharmony_ci   export default {
273e41f4b71Sopenharmony_ci     data:{
274e41f4b71Sopenharmony_ci       left:0,
275e41f4b71Sopenharmony_ci       top:0,
276e41f4b71Sopenharmony_ci     },
277e41f4b71Sopenharmony_ci     dragstart(e){
278e41f4b71Sopenharmony_ci       prompt.showToast({
279e41f4b71Sopenharmony_ci         message: 'Start to be dragged'
280e41f4b71Sopenharmony_ci       })
281e41f4b71Sopenharmony_ci     },
282e41f4b71Sopenharmony_ci     drag(e){
283e41f4b71Sopenharmony_ci       this.left = e.globalX;
284e41f4b71Sopenharmony_ci       this.top = e.globalY;
285e41f4b71Sopenharmony_ci     },
286e41f4b71Sopenharmony_ci     dragend(e){
287e41f4b71Sopenharmony_ci       promptAction.showToast({
288e41f4b71Sopenharmony_ci         message: 'End Drag'
289e41f4b71Sopenharmony_ci       })
290e41f4b71Sopenharmony_ci     }
291e41f4b71Sopenharmony_ci   }
292e41f4b71Sopenharmony_ci   ```
293e41f4b71Sopenharmony_ci
294e41f4b71Sopenharmony_ci   ![9](figures/9.gif)
295e41f4b71Sopenharmony_ci
296e41f4b71Sopenharmony_ci   ```html
297e41f4b71Sopenharmony_ci   <!-- xxx.hml -->
298e41f4b71Sopenharmony_ci   <div class="container">
299e41f4b71Sopenharmony_ci     <div class="content" ondrag="drag" style="position: absolute;left: {{left}};top: {{top}};"></div>
300e41f4b71Sopenharmony_ci     <div style="width: 500px; height: 500px; background-color: yellow; position: fixed; left: 15%; top: 30%; opacity:0.3"
301e41f4b71Sopenharmony_ci       ondragenter="dragenter" ondragover="dragover" ondragleave="dragleave" ondrop="drop">
302e41f4b71Sopenharmony_ci     </div>
303e41f4b71Sopenharmony_ci   </div>
304e41f4b71Sopenharmony_ci   ```
305e41f4b71Sopenharmony_ci
306e41f4b71Sopenharmony_ci   ```css
307e41f4b71Sopenharmony_ci   /* xxx.css */
308e41f4b71Sopenharmony_ci   .container {
309e41f4b71Sopenharmony_ci     flex-direction: column;
310e41f4b71Sopenharmony_ci     width: 100%;
311e41f4b71Sopenharmony_ci     position: relative;
312e41f4b71Sopenharmony_ci     max-width: 100%;
313e41f4b71Sopenharmony_ci   }
314e41f4b71Sopenharmony_ci   .content{
315e41f4b71Sopenharmony_ci     width: 200px;
316e41f4b71Sopenharmony_ci     height: 200px;
317e41f4b71Sopenharmony_ci     background-color: red;
318e41f4b71Sopenharmony_ci     position: absolute;
319e41f4b71Sopenharmony_ci   }
320e41f4b71Sopenharmony_ci   ```
321e41f4b71Sopenharmony_ci
322e41f4b71Sopenharmony_ci   ```js
323e41f4b71Sopenharmony_ci   // xxx.js
324e41f4b71Sopenharmony_ci   import promptAction from '@ohos.promptAction';
325e41f4b71Sopenharmony_ci   export default {
326e41f4b71Sopenharmony_ci     data:{
327e41f4b71Sopenharmony_ci       left:0,
328e41f4b71Sopenharmony_ci       top:0,
329e41f4b71Sopenharmony_ci     },
330e41f4b71Sopenharmony_ci     drag(e){
331e41f4b71Sopenharmony_ci       this.left = e.globalX;
332e41f4b71Sopenharmony_ci       this.top = e.globalY;
333e41f4b71Sopenharmony_ci     },
334e41f4b71Sopenharmony_ci     dragenter(e){
335e41f4b71Sopenharmony_ci       promptAction.showToast({
336e41f4b71Sopenharmony_ci         message: 'enter'
337e41f4b71Sopenharmony_ci       })
338e41f4b71Sopenharmony_ci     },
339e41f4b71Sopenharmony_ci     dragover(e){
340e41f4b71Sopenharmony_ci       promptAction.showToast({
341e41f4b71Sopenharmony_ci         message: 'over'
342e41f4b71Sopenharmony_ci       })
343e41f4b71Sopenharmony_ci     },
344e41f4b71Sopenharmony_ci     dragleave(e){
345e41f4b71Sopenharmony_ci       promptAction.showToast({
346e41f4b71Sopenharmony_ci         message: 'leave'
347e41f4b71Sopenharmony_ci       })
348e41f4b71Sopenharmony_ci     },
349e41f4b71Sopenharmony_ci     drop(e){
350e41f4b71Sopenharmony_ci       promptAction.showToast({
351e41f4b71Sopenharmony_ci         message: 'drop'
352e41f4b71Sopenharmony_ci       })
353e41f4b71Sopenharmony_ci     }
354e41f4b71Sopenharmony_ci   }
355e41f4b71Sopenharmony_ci   ```
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci   ![6](figures/6.gif)
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci5. Pinching<sup>7+</sup>
360e41f4b71Sopenharmony_ci   ```html
361e41f4b71Sopenharmony_ci   <!-- xxx.hml -->
362e41f4b71Sopenharmony_ci   <div class="container">
363e41f4b71Sopenharmony_ci     <div class="content" onpinchstart="pinchstart" onpinchend="pinchend" onpinchupdate="pinchupdate"
364e41f4b71Sopenharmony_ci       onpinchcancel="pinchcancel"> 
365e41f4b71Sopenharmony_ci     </div>
366e41f4b71Sopenharmony_ci   </div>
367e41f4b71Sopenharmony_ci   ```
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ci   ```css
370e41f4b71Sopenharmony_ci   /* xxx.css */
371e41f4b71Sopenharmony_ci   .container {
372e41f4b71Sopenharmony_ci     flex-direction: column;
373e41f4b71Sopenharmony_ci     justify-content: center;
374e41f4b71Sopenharmony_ci     align-items: center;
375e41f4b71Sopenharmony_ci     width: 454px;
376e41f4b71Sopenharmony_ci     height: 454px;
377e41f4b71Sopenharmony_ci   }
378e41f4b71Sopenharmony_ci   .content {
379e41f4b71Sopenharmony_ci     width: 400px;
380e41f4b71Sopenharmony_ci     height: 400px;
381e41f4b71Sopenharmony_ci     background-color: aqua;
382e41f4b71Sopenharmony_ci     margin: 30px;
383e41f4b71Sopenharmony_ci   }
384e41f4b71Sopenharmony_ci   ```
385e41f4b71Sopenharmony_ci
386e41f4b71Sopenharmony_ci   ```js
387e41f4b71Sopenharmony_ci   // xxx.js
388e41f4b71Sopenharmony_ci   import promptAction from '@ohos.promptAction';
389e41f4b71Sopenharmony_ci   export default {
390e41f4b71Sopenharmony_ci     pinchstart(e){
391e41f4b71Sopenharmony_ci       promptAction.showToast({
392e41f4b71Sopenharmony_ci         message: 'pinchstart!!!'
393e41f4b71Sopenharmony_ci       })
394e41f4b71Sopenharmony_ci     },
395e41f4b71Sopenharmony_ci     pinchupdate(e){
396e41f4b71Sopenharmony_ci       promptAction.showToast({
397e41f4b71Sopenharmony_ci         message: 'Two-finger pinch update'
398e41f4b71Sopenharmony_ci       })
399e41f4b71Sopenharmony_ci     },
400e41f4b71Sopenharmony_ci     pinchend(e){
401e41f4b71Sopenharmony_ci       promptAction.showToast({
402e41f4b71Sopenharmony_ci         message: 'Finished with two fingers pinching'
403e41f4b71Sopenharmony_ci       })
404e41f4b71Sopenharmony_ci     },
405e41f4b71Sopenharmony_ci     pinchcancel(e){
406e41f4b71Sopenharmony_ci       promptAction.showToast({
407e41f4b71Sopenharmony_ci         message: 'Finger pinching is interrupted'
408e41f4b71Sopenharmony_ci       })
409e41f4b71Sopenharmony_ci     }
410e41f4b71Sopenharmony_ci   }
411e41f4b71Sopenharmony_ci   ```
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci   ![5](figures/5.gif)
414