asp.net - 静态宽度 DIV 旁边的动态宽度 DIV

标签 asp.net html css

它在标题中。

我试图将页面左侧的一个 div 设置为静态宽度 170px;这很好用。

我遇到的问题是在其旁边添加一个 div,它会缩放以适应剩余宽度。

这里有我可以使用的简单方法吗?

最佳答案

在右侧的 div 上,设置一个边距:

style="margin-left: 170px;"

这是一个示例页面,在这里工作:

<html>
  <head>
    <title>Jquery Test</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
    <script type="text/javascript">
      $(function()  {
        var right = $("#right");
        $("#toggle").click(function() {
          $("#left").animate({"width": "toggle"}, {
            duration: 250,
            step: function() {
                right.css("margin-left", $(this).width());
            }
          }, function() { right.css("margin-left", $("#left").width()); });             
        });
      });
    </script>
    <style type="text/css">
      #left { width: 170px; float: left; border: solid 1px red; }
      #right { margin-left: 170px; border: solid 1px green; }
    </style>
  </head>
  <body>
    <div id="left">Test</div>
    <div id="right">Test Right</div>
    <input id="toggle" value="Open/Close" type="button" />    
  </body>
</html>

关于asp.net - 静态宽度 DIV 旁边的动态宽度 DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2105154/

相关文章:

c# - 安装 sql server 2014 时出现 netfx3 错误?

c# - 是 new Thread(() => {//logic}).Start();可接受在 Web 应用程序 page_load 中执行逻辑 "asynchronously"

asp.net - 无法弄清楚 VS2010 中的 web.debug.config 与 web.config 替代

c# - 当我刷新我的 gridview 时如何到达 page1?

css - 为什么 float div 的顶部与父 div 不对齐?

jquery - 静态页脚,带有附加和缩放重叠

javascript - 如何在 jQuery 对话框中拉伸(stretch) div 和输入元素?

html - 如何在 HTML 中填充边框?

css - 错误的 CSS 验证错误? Aptana 工作室 vs W3-Validator

html - 为什么这不适用于 Firefox?