Reputation: 110562
Is there a way to do the following in plain CSS?
.item {
width: 85% - 1px;
}
In other words, I want the item to be 85% width, minus one pixel (ignore a border).
How would I accomplish this?
Upvotes: 2
Views: 63
Reputation: 4501
maybe use box-sizing: border-box
?
https://developer.mozilla.org/ru/docs/Web/CSS/box-sizing
div{
height: 50px;
width: 85%;
border: 1px solid #f00;
background: #ccc;
margin: 15px auto;
}
.box-sizing{
box-sizing: border-box;
}
<div></div>
<div class="box-sizing"></div>
Upvotes: 1
Reputation: 26444
There is a CSS calc
function.
https://developer.mozilla.org/en-US/docs/Web/CSS/calc
In your case, it would look like this
width: calc(85% - 1px);
Upvotes: 3
Reputation: 1126
Though it won't work in legacy browsers
width: calc(85% - 1px);
Upvotes: 3