专修虚拟机 2015-12-15 09:34 采纳率: 0%
浏览 2081

<div style="clear:both"></div>的用法?

用js写了个计算器为什么在写页面时需要在最后加个

 <div style="clear:both"></div>啊?
 不加的话 计算器的左右下边框就没了!
 <div style="clear:both"></div>这个应该怎么用啊?
 什么情况需要加这个啊?
 <style type="text/css">
     为方便观看 之列出了含float的样式
            .panel p, .panel input {
        font-family: "微软雅黑";
        font-size: 20px;
        margin: 4px;
        float: left;
        border-radius: 4px;
      }
          .panel p {
        width: 122px;
        height: 26px;
        border: 1px solid #ddd;
        padding: 6px;
        overflow: hidden;
      }

    </style>

        <body>
        <div class="panel" onclick="cal(event);">
      <div>
        <p id="screen"></p>
        <input type="button" value="C">
        <div style="clear:both"></div>
      </div>
      <div>
        <input type="button" value="7">
        <input type="button" value="8">
        <input type="button" value="9">
        <input type="button" value="/">

        <input type="button" value="4">
        <input type="button" value="5">
        <input type="button" value="6">
        <input type="button" value="*">

        <input type="button" value="1">
        <input type="button" value="2">
        <input type="button" value="3">
        <input type="button" value="-">

        <input type="button" value="0">
        <input type="button" value=".">
        <input type="button" value="=">
        <input type="button" value="+">

        <div style="clear:both"></div>
      </div>
    </div>    
  </body>


  • 写回答

4条回答 默认 最新

  • qq_33388101 2015-12-15 10:11
    关注

    应该是清除float

    评论

报告相同问题?