bootstrap设置表格高度自适应的方法 - 网站

bootstrap设置表格高度自适应的方法

分类:Bootstrap框架进阶教程_Bootstrap技术文章 · 发布时间:2020-11-21 10:22 · 阅读:1636

bootstrap元素高度自适应解决方案

很多人会使用boot的栅格化布局,但是高度却不知道怎么等比例控制,本文就详细介绍使用bootstrap框架构建前端页面时如何控制元素高度自适应布局。

方法/步骤

首先我们在页面头部引用一段JS

js代码片段如下:

var iScale = 1;
iScale = iScale / window.devicePixelRatio;  
document.write('<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=' + iScale + ',minimum-scale=' + iScale + ',maximum-scale=' + iScale + '">') 
var iWidth = document.documentElement.clientWidth;
document.getElementsByTagName('html')[0].style.fontSize = iWidth / 16 + 'px';

注意:要在文档加载前引入,否则不生效。

当引入成功后就可以看到文档html元素上会出现font-size属性。

其次就是css我们要用less撰写,主要是less有计算功能,关于less使用,请参考less官网。

less计算样式代码段:

@s:46.875rem;
@color:~"div[class^='col']";
@{color}{
    background: #999;
    height: 200/@s;
  }

如上代码表示将.color类添加了100像素的高度,那么计算出来,当然200像素就直接200/@s; 就可以了。 变量的值不固定,是动态计算出来的字体大小,值的大小根据实际设计图的尺寸计算。

标签:
bootstrap

相关文章

bootstrap如何实现table表格超过长度不显示

bootstrap实现table表格超过长度不显示的方法:可以通过text-overflow和max-width属性来实现,如【&quot;white-space&quot;: &quot;nowrap&quot;,&quot;text-overflow&quot;: &quot;ellipsis&quot;】。

在bootstrap如何将图片全屏显示

bootstrap将图片全屏显示的方法:1、使用“&lt;div class=&quot;container&quot;&gt;&lt;/div&gt;”方式;2、使用“&lt;div class=&quot;container-fiuled&quot;&gt;&lt;/div&gt;”方式。

bootstrap表格显示不出来数据怎么办

bootstrap表格显示不出来数据的解决办法:1、清理下浏览器缓存;2、修改JSON数据格式;3、修改js的bootstraptable配置。

bootstrap怎么让div水平居中

bootstrap让div水平居中的方法:首先打开相应的代码文件;然后使用“&lt;div d-flex justify-content-center&quot;&gt;&lt;div class=&quot;align-self-center&quot;&gt;”实现居中即可。

bootstrap小图标替换的方法

bootstrap小图标替换的方法:首先使用“&lt;span class=&quot;glyphicon glyphicon-search&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;”;然后将glyphicon-search替换即可。

返回分类 返回首页