您可以使用calc() 函数来处理这个问题,它将使用视口高度的给定百分比以及其他一些显式计算: /* This assumes you have a background-size class */ .background-image { /* This sets the height to 100% of the viewport height minus 50px */ height: calc(100vh - 50px); } 您也可以使用您喜欢的...
div{ height:100vh; background-color:gray; } - Mohit Sharma 5 现在有了css3,你可以试着使用calc()函数。 .main{ height: calc(100% - 111px); } 请看这个答案:Div width 100% minus fixed amount of pixels。这个答案涉及到IT技术。 - RaphKomjat 1 我猜你在尝试获取吸底部 - n1313...
CSScalc()Function ❮ CSS Functions Reference Example Use calc() to calculate the width of a element: #div1{ position:absolute; left:50px; width:calc(100% - 100px); border:1px solid black; background-color:yellow; padding:5px; text-align...
.content { min-height: calc(100vh - 120px); /* 80px header + 40px footer = 120px */ } Which means: let the height of the content div be at least 100% of the viewport height minus the combined heights of the header and footer. That's it. Show code snippet ... an...
根据official article on Chrome web,设置填充可见视口的高度的正确方法是使用height: 100%,可以在元素...
根据official article on Chrome web,设置填充可见视口的高度的正确方法是使用height: 100%,可以在元素...
calc()is for values The only place you can use thecalc()function is invalues. See these examples where we’re setting the value for a number of different properties. .el{font-size:calc(3vw+2px);width:calc(100%-20px);height:calc(100vh-20px);padding:calc(1vw+5px);} ...
Lorem ipsum dolor sit amet consectetur adipisicing elit. Asperiores laudantium quas reprehenderit ...
另外class和属性化的负数值写法是不同 <!--这里mb--20 可以理解为 margin-bootom:-20px--> Lorem ipsum, dolor sit amet consectetur adipisicing elit. Explicabo veniam aut esse iure mollitia. Earum omnis aliquid minus porro nulla commodi dignissimos, voluptatem accusamus cumque reprehend...
height: calc(var(--a) + 7px); We need to keep a few things in mind to ensure that thecalc()function works. First, division by zero obviously won’t work. Having a space between the function name and the parenthesis is not allowed. And the plus and minus operators must be surrounded...