calc() css code example

Example 1: css calc height

div {
	width: calc(100% - 100px);
}

Example 2: css calc

body {
  width: calc(100vw - 8px);
  height: calc(100vh - 8px);
}

Example 3: grid-template-areas css

#page {
  display: grid;
  width: 100%;
  height: 250px;
  grid-template-areas: "head head"
                       "nav  main"
                       "nav  foot";
  grid-template-rows: 50px 1fr 30px;
  grid-template-columns: 150px 1fr;
}

#page > header {
  grid-area: head;
  background-color: #8ca0ff;
}

#page > nav {
  grid-area: nav;
  background-color: #ffa08c;
}

#page > main {
  grid-area: main;
  background-color: #ffff64;
}

#page > footer {
  grid-area: foot;
  background-color: #8cffa0;
}

Example 4: calc() css

.banniere {
  position: absolute;
  left: 40px;
  width: calc(40px - 80px);
  border: solid black 1px;
  box-shadow: 1px 2px;
  background-color: yellow;
  padding: 6px;
  text-align: center;
  box-sizing: border-box;
}

Tags:

Html Example