css width 100% code example
Example 1: width css property
/* <length> values */
width: 300px;
width: 25em;
/* <percentage> value */
width: 75%;
/* Keyword values */
width: max-content;
width: min-content;
width: fit-content(20em);
width: auto;
/* Global values */
width: inherit;
width: initial;
width: unset;
Example 2: width css
/*Based on viewport*/
width: 100vh;
width: 100vw;
Example 3: css 100% height
<!DOCTYPE html>
<html>
<head>
<title>100% height</title>
<style>
html,
body {
height: 100%;
margin: 0;
}
.container {
height: 100%;
background: #000;
}
</style>
</head>
<body>
<div class="container"></div>
</body>
</html>
Example 4: what does it mean when we write width :100%?
if you specify width:100%, the element's total width will be 100% of its containing block plus any horizontal margin, padding and border