将元素的高度设置为数字的倍数? [英] Set height of an element on multiples of a number?

查看:132
本文介绍了将元素的高度设置为数字的倍数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有任何方式通过jquery或javascript来使元素的高度扩展到一组数字?我的意思是,因为它容纳更多的内容,它的高度只会遵循数字的模式(数字的倍数)。

Is there any way via jquery or javascript to make an element stretch its height to a certain set of numbers? I mean, as it accommodates more content, its height would only follow a pattern of numbers (multiples of a number).

我们假设为100的倍数... div的高度,因为它的高度只有在这个系列中 - 200像素,300像素,400像素等。因此,如果它超过了200个像素只有1像素,它会自动调整为300.

Let's say in multiples of 100... a div's height as it extends taller would only be in this series -- 200px, 300px, 400px, etc. Hence, if it exceeds by just even 1 pixel off 200, it would automatically resize to 300.

很难解释。

我需要这个,因为我做了一个垂直无缝模式撕裂的边缘,如果它完全显示每个瓷砖完全看起来完美。

I need this because I made a vertically seamless pattern with torn edges and it would totally look perfect if it shows each tile completely.

我只知道基本的jquery和我

I only know basic jquery and I don't have a bit of an idea on how to work this out.

我最衷心的感谢谁倾向于我的查询!

My sincerest gratitude to whoever tends to my query!

推荐答案

var h = $('div').height();
$('div').height( Math.ceil(h/100) * 100 );

这篇关于将元素的高度设置为数字的倍数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆