You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/1-document/09-size-and-scroll/article.md
+28-28Lines changed: 28 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ L'immagine sopra rappresenta il caso più complesso in cui l'elemento ha una bar
37
37
Senza la barra di scorrimento, pertanto, l'area del contenuto sarebbe `300px`, ma se la barra di scorrimento è larga `16px` (la larghezza è variabile in base al dispositivo ed al browser) allora rimane soltanto `300 - 16 = 284px`, ed è questa la misura che dovremmo tenere in considerazione. Ecco perché gli esempi di questo capitolo presumono che ci sia una barra di scorrimento. Senza questa, alcuni calcoli sono più semplici.
38
38
```
39
39
40
-
```smart header="L'area del `padding-bottom` può essere riempita dal testo"
40
+
```smart header="L'area del `padding-bottom` può essere occupata dal testo"
41
41
Di solito gli spazi definiti dai padding sono rappresentati vuoti nelle immagini, ma se nell'elemento c'è molto testo ed eccede l'area del contenuto, in quel caso è normale che il browser mostri il testo eccedente nel `padding-bottom`.
42
42
```
43
43
@@ -84,7 +84,7 @@ Nell'esempio di seguito il `<div>` interno ha `<main>` come `offsetParent` e `of
84
84
85
85
Ci sono alcune circostanze in cui `offsetParent` è `null`:
86
86
87
-
1. Per gli elementi nascosti (`display:none` oppure non inserito nel documento).
87
+
1. Per gli elementi nascosti (`display:none` oppure non inseriti nel documento).
88
88
2. Per `<body>` e `<html>`.
89
89
3. Per gli elementi con `position:fixed`.
90
90
@@ -166,26 +166,26 @@ In assenza di padding, dunque, possiamo usare `clientWidth/clientHeight` per ric
166
166
167
167
## scrollWidth/Height
168
168
169
-
Queste proprietà sono come `clientWidth/clientHeight`, ma includono anche le parti nascoste dallo scorrimento:
169
+
Queste proprietà sono come `clientWidth/clientHeight`, ma includono anche le parti fuori dall'area visibile di scorrimento (non visibili):
170
170
171
171

172
172
173
-
On the picture above:
173
+
Nell'immagine sopra:
174
174
175
-
-`scrollHeight = 723` -- is the full inner height of the content area including the scrolled out parts.
176
-
-`scrollWidth = 324` -- is the full inner width, here we have no horizontal scroll, so it equals`clientWidth`.
175
+
-`scrollHeight = 723` -- è l'intera altezza del contenuto includendo le parti fuori dall'area visibile di scorrimento.
176
+
-`scrollWidth = 324` -- è l'intera larghezza, dal momento che non c'è barra di scorrimento orizzontale equivale a`clientWidth`.
177
177
178
-
We can use these properties to expand the element wide to its full width/height.
178
+
Possiamo servirci di queste proprietà per espandere l'elemento fino alla sua larghezza/altezza completa.
179
179
180
-
Like this:
180
+
In questo modo:
181
181
182
182
```js
183
-
//expand the element to the full content height
183
+
//espande l'elemento fino alla sua altezza completa
184
184
element.style.height=`${element.scrollHeight}px`;
185
185
```
186
186
187
187
```online
188
-
Click the button to expand the element:
188
+
Premi il pulsante per espandere l'elemento:
189
189
190
190
<div id="element" style="width:300px;height:200px; padding: 0;overflow: auto; border:1px solid black;">text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text</div>
191
191
@@ -194,27 +194,27 @@ Click the button to expand the element:
194
194
195
195
## scrollLeft/scrollTop
196
196
197
-
Properties `scrollLeft/scrollTop`are the width/height of the hidden, scrolled out part of the element.
197
+
Le proprietà `scrollLeft/scrollTop`sono la larghezza/altezza delle parti di un elemento nascoste e fuori dall'area visibile di scorrimento.
198
198
199
-
On the picture below we can see`scrollHeight`and`scrollTop`for a block with a vertical scroll.
199
+
Nell'immagine sotto possiamo osservare la rappresentazione di`scrollHeight`e`scrollTop`per un blocco soggetto a scorrimento verticale.
200
200
201
201

202
202
203
-
In other words, `scrollTop`is "how much is scrolled up".
203
+
In altre parole, con `scrollTop`si intende "quanto l'elemento è stato fatto scorrere verso l'alto".
204
204
205
-
````smart header="`scrollLeft/scrollTop`can be modified"
206
-
Most of the geometry properties here are read-only, but`scrollLeft/scrollTop`can be changed, and the browser will scroll the element.
205
+
````smart header="`scrollLeft/scrollTop`possono essere modificate"
206
+
La maggior parte delle proprietà geometriche trattate sono in sola lettura, ma`scrollLeft/scrollTop`possono essere modificate, e il browser farà scorrere l'elemento.
207
207
208
208
```online
209
-
If you click the element below, the code `elem.scrollTop += 10` executes. That makes the element content scroll `10px` down.
209
+
Nell'elemento sottostante ogni clic esegue il codice `elem.scrollTop += 10`. Ciò comporta che il contenuto dell'elemento scorre verso il basso di `10px`.
Setting`scrollTop`to`0`or a big value, such as `1e9` will make the element scroll to the very top/bottom respectively.
214
+
Impostare`scrollTop`a`0`o su un grande valore, come `1e9`, farà sì che l'elemento scorrerà rispettivamente verso l'estremità superiore o inferiore.
215
215
````
216
216
217
-
## Don't take width/height from CSS
217
+
## Non ricavare la larghezza o l'altezza dai CSS
218
218
219
219
We've just covered geometry properties of DOM elements, that can be used to get widths, heights and calculate distances.
220
220
@@ -261,16 +261,16 @@ On a Desktop Windows OS, Firefox, Chrome, Edge all reserve the space for the scr
261
261
262
262
Please note that the described difference is only about reading `getComputedStyle(...).width` from JavaScript, visually everything is correct.
263
263
264
-
## Summary
264
+
## Riepilogo
265
265
266
-
Elements have the following geometry properties:
266
+
Gli elementi hanno le seguenti proprietà geometriche:
267
267
268
-
- `offsetParent` -- is the nearest positioned ancestor or `td`, `th`, `table`, `body`.
269
-
- `offsetLeft/offsetTop` -- coordinates relative to the upper-left edge of `offsetParent`.
270
-
- `offsetWidth/offsetHeight` -- "outer" width/height of an element including borders.
271
-
- `clientLeft/clientTop` -- the distances from the upper-left outer corner to the upper-left inner (content + padding) corner. For left-to-right OS they are always the widths of left/top borders. For right-to-left OS the vertical scrollbar is on the left so `clientLeft` includes its width too.
272
-
- `clientWidth/clientHeight` -- the width/height of the content including paddings, but without the scrollbar.
273
-
- `scrollWidth/scrollHeight` -- the width/height of the content, just like `clientWidth/clientHeight`, but also include scrolled-out, invisible part of the element.
274
-
- `scrollLeft/scrollTop` -- width/height of the scrolled out upper part of the element, starting from its upper-left corner.
268
+
- `offsetParent` -- è l'antenato più vicino posizionato (cioè con proprietà `position` diversa da `static`), oppure `td`, `th`, `table`, `body`.
269
+
- `offsetLeft/offsetTop` -- le coordinate relative all'angolo in alto a sinistra di `offsetParent`.
270
+
- `offsetWidth/offsetHeight` -- la larghezza/altezza "esterne" di un elemento bordi inclusi.
271
+
- `clientLeft/clientTop` -- le distanze dell'angolo esterno superiore sinistro dall'angolo interno (contenuto + padding) superiore sinistro. Per le lingue da sinistra verso destra corrispondono sempre alla larghezza dei bordi superiore e sinistro. Per le lingue da destra verso sinistra la barra di scorrimento verticale è a sinistra, quindi `clientLeft` include anche la larghezza della barra.
272
+
- `clientWidth/clientHeight` -- la larghezza/altezza del contenuto, padding inclusi ma senza la barra di scorrimento.
273
+
- `scrollWidth/scrollHeight` -- la larghezza/altezza del contenuto, proprio come `clientWidth/clientHeight`, ma comprende anche la parte di un elemento nascosta e fuori dall'area visibile di scorrimento.
274
+
- `scrollLeft/scrollTop` -- la larghezza/altezza della parte superiore di un elemento fuori dall'area visibile di scorrimento, partendo dal suo angolo in alto a sinistra.
275
275
276
-
All properties are read-only except `scrollLeft/scrollTop` that make the browser scroll the element if changed.
276
+
Tutte le proprietà sono in sola lettura tranne `scrollLeft/scrollTop` che che fanno scorrere l'elemento nel browser se modificate.
0 commit comments