Skip to content

Commit 02bd539

Browse files
docs(common): dimensions examples
1 parent 04333e4 commit 02bd539

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

common-features/dimensions.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,63 @@ For elements with **special positioning** (`Top` and `Left` properties), keep in
2020

2121
When setting **percentage values** (such as `100%` or `50%`), keep in mind the following - according to the web standards, elements which have their height set in percentage require that the height of their parent is also explicitly set. This requirement applies recursively until either an element with a pixel height or the html element is reached. Elements that are 100% high should not have margins, paddings, borders, or sibling elements.
2222

23+
## Examples
24+
25+
The examples here showcase different units and examples of using them to set dimensions and positions. The results you get may vary from the screenshots here because of different CSS rules in your project and different browser/screen sizes. Review the explanations in the code for more details on what to expect.
26+
27+
>caption Setting sizes in different dimensions (percent, pixel, vw in this sample)
28+
29+
````CSHTML
30+
<div style="width: 500px; border: 1px solid red;">
31+
<TelerikTextBox Width="50%" />
32+
<br />
33+
<TelerikTextBox Width="100px" />
34+
<br />
35+
<TelerikTextBox Width="10vw" />
36+
</div>
37+
````
38+
39+
![](images/basic-width-settings.png)
40+
41+
42+
>caption Using auto width to have an element adjust to its contents
43+
44+
````CSHTML
45+
<TelerikDropDownList Data="@MyList" @bind-Value="MyItem" PopupWidth="auto" PopupHeight="auto">
46+
</TelerikDropDownList>
47+
48+
@code {
49+
protected List<string> MyList = new List<string>()
50+
{
51+
"first",
52+
"second very long item that determines the width of the dropdown element",
53+
"third"
54+
//if you have many items, avoid PopupHeight="auto" because it will go off the screen
55+
};
56+
57+
protected string MyItem { get; set; } = "third";
58+
}
59+
````
60+
61+
![](images/auto-size-for-dropdown.png)
62+
63+
64+
65+
>caption Position is controlled by the parent element with special positioning
66+
67+
````CSHTML
68+
<TelerikWindow Visible="true" Top="100px" Left="100px" Width="30vw" Height="40vh">
69+
<WindowContent>
70+
The parent element of the window is the TelerikRootComponent which should match the app element and the viewport.
71+
<br />
72+
This window will be 100px off the top left corner of the viewport in a blank app without special CSS rules. You can also use other units, such as percent.
73+
<br />
74+
Also, the size of this window will depend on the viewport size - resize your browser to see the effects.
75+
</WindowContent>
76+
<WindowTitle>Examples of offsets and dimensions</WindowTitle>
77+
</TelerikWindow>
78+
````
79+
80+
81+
![](images/parent-element-offset.png)
82+
4.61 KB
Loading
938 Bytes
Loading
29.4 KB
Loading

0 commit comments

Comments
 (0)