html - 如何创建一个方形 div,其宽度和高度完全等于响应式字符的高度?
问题描述
我想创建一个div
,其中width
andheight
完全等于 1 个字符的高度,并且宽度和高度应该是响应式的:如果我改变字体大小,宽度和高度也会改变。我试过了 :
<table border="1" style="position:relative;">
<tr>
<td style="font-size:144px"> 
<div style="position:absolute;top:0%;left:0%;background-color:red;width:100%;padding-bottom:100%;"/>
</td>
</tr>
</table>
红色方块的边自动等于width
“ ”的边。但我希望它等于height
“ ”,我试过:
<table border="1" style="position:relative;">
<tr>
<td style="font-size:144px"> 
<div style="position:absolute;top:0%;left:0%;background-color:red;height:100%;padding-right:100%;"></div>
</td>
</tr>
</table>
只是用“height”替换“width”,用“padding-right”替换“padding-bottom”,但似乎不起作用,有什么办法吗?
解决方案
推荐阅读
- sql - 如何在不同列上的名字和姓氏的不同行上搜索多个名称?
- r - 通过循环将同一列添加到多个数据框中
- sql - SQL - 从一个表和另外两个表中查询与日期范围相关的
- r - 如何将 R 中的多个数据框合并为一个较小的数据框(减少列数)?
- python - Python Django 重复循环
- sql - 如何使用连接重写子查询
- python - 丢弃多个excel中的初始报告并创建一个数据框pandas
- javascript - 阻止用户使用 url 访问文件
- ios - Collection View如何创建TableView Header
- sql - SQL Server 表值函数没有为函数提供参数 -