它在标题中。
我试图将页面左侧的一个 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/