如何使button自动填充table的单元格

【题目需求】:如何使button自动填充table的单元格

原代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算器</title>
    <script>
        input:{
            style="width:100%";
        }
    </script>
</head>
<body>
<table border="1">
    <thead>
    <tr>
        <td colspan="4"><input style="height:50px" type="text"></td>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td><input type="button" value="7"></td>
        <td><input type="button" value="4"></td>
        <td><input type="button" value="1"></td>
        <td><input type="button" value="="></td>
    </tr>
    <tr>
        <td><input type="button" value="8"></td>
        <td><input type="button" value="5"></td>
        <td><input type="button" value="2"></td>
        <td><input type="button" value="0"></td>
    </tr>
    <tr>
        <td><input type="button" value="9"></td>
        <td><input type="button" value="6"></td>
        <td><input type="button" value="3"></td>
        <td><input type="button" value="."></td>
    </tr>
    <tr>
        <td><input type="button" value="+"></td>
        <td><input type="button" value="-"></td>
        <td><input type="button" value="*"></td>
        <td><input type="button" value="/"></td>
    </tr>
    </tbody>
</table>
<script></script>
</body>
</html>

原代码输出:

样例输出:

 

【解决方式】

方式一:针对单条语句
<td><input style="width:100%" type="button" value="8"></td>

方式二:针对整体样式修改在 

<head> 
<style> 
       input{
             width: 100%; 
            } 
</style> 
</head>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值