Skip to content

Commit 516abff

Browse files
committed
Update 2-ui\1-document\09-size-and-scroll\article.md
1 parent 553dbfc commit 516abff

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

2-ui/1-document/09-size-and-scroll/article.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ L'immagine sopra rappresenta il caso più complesso in cui l'elemento ha una bar
3737
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.
3838
```
3939

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"
4141
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`.
4242
```
4343
@@ -84,7 +84,7 @@ Nell'esempio di seguito il `<div>` interno ha `<main>` come `offsetParent` e `of
8484

8585
Ci sono alcune circostanze in cui `offsetParent` è `null`:
8686

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).
8888
2. Per `<body>` e `<html>`.
8989
3. Per gli elementi con `position:fixed`.
9090

@@ -166,26 +166,26 @@ In assenza di padding, dunque, possiamo usare `clientWidth/clientHeight` per ric
166166

167167
## scrollWidth/Height
168168

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):
170170

171171
![](metric-scroll-width-height.svg)
172172

173-
On the picture above:
173+
Nell'immagine sopra:
174174

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`.
177177

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.
179179

180-
Like this:
180+
In questo modo:
181181

182182
```js
183-
// expand the element to the full content height
183+
// espande l'elemento fino alla sua altezza completa
184184
element.style.height = `${element.scrollHeight}px`;
185185
```
186186

187187
```online
188-
Click the button to expand the element:
188+
Premi il pulsante per espandere l'elemento:
189189
190190
<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>
191191
@@ -194,27 +194,27 @@ Click the button to expand the element:
194194

195195
## scrollLeft/scrollTop
196196

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.
198198

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.
200200

201201
![](metric-scroll-top.svg)
202202

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".
204204

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.
207207

208208
```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`.
210210
211211
<div onclick="this.scrollTop+=10" style="cursor:pointer;border:1px solid black;width:100px;height:80px;overflow:auto">Click<br>Me<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9</div>
212212
```
213213

214-
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.
215215
````
216216
217-
## Don't take width/height from CSS
217+
## Non ricavare la larghezza o l'altezza dai CSS
218218
219219
We've just covered geometry properties of DOM elements, that can be used to get widths, heights and calculate distances.
220220
@@ -261,16 +261,16 @@ On a Desktop Windows OS, Firefox, Chrome, Edge all reserve the space for the scr
261261
262262
Please note that the described difference is only about reading `getComputedStyle(...).width` from JavaScript, visually everything is correct.
263263
264-
## Summary
264+
## Riepilogo
265265
266-
Elements have the following geometry properties:
266+
Gli elementi hanno le seguenti proprietà geometriche:
267267
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.
275275
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

Comments
 (0)