This content originally appeared on Manuel Matuzović - Web development blog and was authored by Manuel Matuzović
There are logical properties for width and height values.
width and height
The logical alternative for width
is inline-size
and the alternative for height
is block-size
. Here’s an example of how using inline-size
over width
makes a difference.
If you use width
, the property sets the physical width, regardless of the writing mode.
h1 {
border: 1rem solid;
padding: 1rem;
width: 16rem;
}
.vertical {
writing-mode: vertical-rl;
}
<h1>width horizontal</h1>
<h1 class="vertical">width vertical</h1>
width horizontal
width vertical
If you use inline-size
, the property sets the logical width with respect to the writing mode.
h1 {
border: 1rem solid;
padding: 1rem;
inline-size: 16rem;
}
.vertical {
writing-mode: vertical-rl;
}
inline-size horizontal
inline-size vertical
vi and vb
There are also logical unit alternatives for vw
and vh
.
The width and height of the <div>
is always the width and height of the viewport, regardless of the writing mode.
div {
border: 1rem solid;
width: 20vw;
height: 40vh;
}
.vertical {
writing-mode: vertical-rl;
}
vw + vh
vw + vh
The width and height of the <div>
matches either the vertical or horizontal dimensions of the viewport, depending on the writing mode.
div {
border: 1rem solid;
width: 20vi;
height: 40vb;
}
vi + vb
vi + vb
50vw
alternative:50vi
50vh
alternative:50vb
50dvh
alternative:50dvb
50svh
alternative:50svb
50lvh
alternative:50lvb
My blog doesn't support comments yet, but you can reply via blog@matuzo.at.
This content originally appeared on Manuel Matuzović - Web development blog and was authored by Manuel Matuzović
Manuel Matuzović | Sciencx (2023-01-10T09:38:54+00:00) Day 77: block-size, inline-size, vi, and vb. Retrieved from https://www.scien.cx/2023/01/10/day-77-block-size-inline-size-vi-and-vb/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.