栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

高度:calc(100%)在CSS中无法正常工作

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

高度:calc(100%)在CSS中无法正常工作

您需要确保将html和body设置为100%,还必须确保为calc添加供应商前缀,因此-moz-calc和-webkit-calc都是如此。

以下CSS作品:

html,body {    background: blue;    height:100%;    padding:0;    margin:0;}header {    background: red;    height: 20px;    width:100%}h1 {    font-size:1.2em;    margin:0;    padding:0;    height: 30px;    font-weight: bold;    background:yellow}#theCalcDiv {    background:green;    height: -moz-calc(100% - (20px + 30px));    height: -webkit-calc(100% - (20px + 30px));    height: calc(100% - (20px + 30px));    display:block}

我还在html和body上将margin / padding设置为0,否则将添加滚动条。

浏览器支持:IE9 +,Firefox 16+以及供应商前缀Firefox 4 +,Chrome 19 +,Safari 6+



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/596914.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号