Categories CSS How to set width/height as a percentage minus pixels with CSS? Post author By John Au-Yeung Post date February 13, 2023 No Comments on How to set width/height as a percentage minus pixels with CSS? Spread the love To set width/height as a percentage minus pixels with CSS, we use calc. For instance, we write div { height: calc(100% - 18px); } to set the div’s height to 100% minus 18px with calc. Related Posts How to restrict max text area width and height?Sometimes, we want to restrict max text area width and height. In this article, we'll… How to transition height: 0; to height: auto; using CSS?Sometimes, we want to transition height: 0; to height: auto; using CSS. In this article,… How to set element width or height in JavaScript?Sometimes, we want to set element width or height in JavaScript. In this article, we'll… By John Au-Yeung Web developer specializing in React, Vue, and front end development. View Archive → ← How to center a position: fixed element with CSS? → How to prevent body scrolling but allow overlay scrolling with CSS? Leave a Reply Cancel replyYour email address will not be published. Required fields are marked *Comment * Name * Email * Website Save my name, email, and website in this browser for the next time I comment. Current ye@r * Leave this field empty