我在拖放的帮助下制作厨房布局。如果我为厨房选择10 X 10的布局,则必须在该区域进行一些验证。假设我将一个5x5的墙放到该区域,那么如何找到剩余的高度和宽度以及它在哪里放置vartical或水平...
答案 0 :(得分:2)
假设您的厨房布局和墙壁
<body>
<div class="kitchen">
<div class="wall">
</div>
</div>
</body>
上面应该是你html的原型
现在使用:
var wallHeight = $('.wall').height(); // Gives wall's height
var wallWidth = $('.wall').width(); // Gives wall's width
var kitchenHeight = $('.kitchen').height(); // Gives kitchen height
var kitchenWidth = $('.kitchen').width(); // Gives kitchen width
var leftHeight = kitchenHeight - wallHeight,
leftWidth = kitchenWidth - wallWidth;
// Gives remaining width and height