zoukankan      html  css  js  c++  java
  • 多控件时,自适应布局(dl dd td )

    现象:

    当改变浏览器宽度变小时,常常因为控件太多,导致改变布局,使得混乱不堪。

    代码:

    <script type="text/javascript">
      $(document).ready(function () { 
        $("#op_div").css("padding-top", $("#search_div").height() + 5); //div自动高度
        });
    </script>
    
    <div id="search_div" class="tt-attach" style="height: 80px;">
    <dl>
            <dd>
                学号:</dd>
            <dt>
               @Html.TextBox("No_Search", "", new
                   {
                       style = "135px;",
                       title = "请输入学号进行搜索"
                   })</dt>
            </dt>
        </dl>
        <dl>
            <dd>
                姓名:</dd>
            <dt>@Html.TextBox("Name_Search", "", new
                   {
                       style = "135px;",
                       title = "请输入姓名进行搜索"
                   })</dt>
        </dl>
      <input id="btnSearch" class="btns" value="搜索" type="button" />
    </div>
    <div id="op_div" style="clear:both;"></div> //"clear:both;"清除浮动,避免改变之后内容的布局

    CSS:

    .tt-attach dl
    {
         220px;
        display: block;
        float: left;
        height: 25px;
        line-height: 30px;
        padding: 0px;
    }
    .tt-attach dl dd
    {
         70px;
        display: block;
        float: left;
        height: 25px;
        line-height: 30px;
        margin: 0px;
        text-align: right;
        padding: 0px;
    }
    .tt-attach dl dt
    {
         150px;
        display: block;
        float: left;
        height: 25px;
        line-height: 30px;
        margin: 0px;
        text-align: right;
        padding: 0px;
    }
    .tt-attach .btns
    {
        display: block;
        float: left;
        padding: 0px;
        margin-left: 10px;
        margin-top: 5px;
    }



  • 相关阅读:
    149. Max Points on a Line(js)
    148. Sort List(js)
    147. Insertion Sort List(js)
    146. LRU Cache(js)
    145. Binary Tree Postorder Traversal(js)
    144. Binary Tree Preorder Traversal(js)
    143. Reorder List(js)
    142. Linked List Cycle II(js)
    141. Linked List Cycle(js)
    140. Word Break II(js)
  • 原文地址:https://www.cnblogs.com/xcsn/p/2921207.html
Copyright © 2011-2022 走看看