CSS calc percentage divided by x then minus 1 px?

Evanss

Im use CSS calc to make 7 items the correct width to sit side by side:

width: calc(100% / 7);

This works fine in most browsers but sometimes IE rounds up, making the last item clear to the next line. How can I subtract 1px from the width?

width: calc((100% / 7) -1px);
Paulie_D

For better support than Flexbox, use CSS Tables as a solution and avoid the whole calc requirement in the first place.

Support is good as far back as IE8

.wrapper {
  width: 100%;
  background-color: #bada55;
  display: table;
  table-layout: fixed;
}
.wrapper div {
  display: table-cell;
  height: 70px;
  background-color: rebeccapurple;
  border: 1px solid orange;
}
<div class="wrapper">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

CSS PX to Percentage

possible to flex: 1 and minus px?

css gradient 1 color fill 40px and another fill calc(100%-40px)

Is it possible to use vh minus pixels in a CSS calc()?

CSS: Setting width/height as Percentage minus pixels

mixing percent and px in css without using calc()

CSS calc() percentage rest division multiplication

Angular compilation .less is calculating pixels as percentage: 'calc(100% - 26px)' to 'calc(76%)

How do I use calc(100%-50px) to minus the pixels from the top?

JavaScript: How to get the px value of a calc() css property?

Why is CSS calc(100%-250px) not working?

CSS2 version of height: calc(100% - 18px)

CSS Calc() using two pixel amounts to get a percentage

Percentage Plus and Minus

display:table div with percentage width 1px bug

Is calc(--x - y) a valid CSS syntax?

The calc() returns percentage, not pixels?

CSS Calc - always achieve '0' or '1'

Why the firstsection CSS class needs calc(100% - 70px) instead of calc(100% - 75px) to not have a scrolldown bar in CSS and HTML?

Calculating fluid CSS element sizes using CSS using calc(px + vw)

Sass calculate percent minus px

css border: 1px appear as 0.667px or 1px depending on the computer / display resolution (?)

CSS border less than 1px

CSS sticky ignores 1px

:Inf x 1 divided by :Inf x 1 yields :Inf x :Inf Matlab

Can I position my CSS background to "bottom minus x pixels"?

Flexbox space-between has extra 1px gap at the end when using calc()

Calc percentage in IE11

How to calc percentage of interval in array