- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的网站上使用了一个脚本,它计算具有相同 .sh 类的其他 div 的最高高度。两者的高度相同。这可以工作,但在视口(viewport) < 680 上它不需要工作。另外,在调整视口(viewport)大小时,高度不会更新/重新计算。
谁能帮我解决这个问题吗?
我举了一个例子。 https://jsfiddle.net/ctb9f3c1/
jQuery(document).ready(resizeTheHeights);
function resizeTheHeights() {
var allHeights = [];
$('.sh').each(function() {
var thisHeight = $(this).height();
allHeights.push(thisHeight);
});
var highestHeight = Math.max.apply(Math, allHeights);
$('.sh').height(highestHeight);
}
最佳答案
我已经更新了一个应该有效的解决方案。您应该在调整大小事件上调用该函数,并在函数中添加一个检查以返回窗口宽度是否小于 680。
jQuery(document).ready(function init() {
resizeTheHeights();
$( window ).resize(function() { //this is for on resize trigger of this function
resizeTheHeights();
});
}());
function resizeTheHeights(allHeights ) {
if ($( window ).width() < 680) {
$('.sh').height(''); //set this to 'auto' if you havent set heights specifically in css, as in my fiddle
return; //this makes it not work for heights less than 680
}
var allHeights = [];
$('.sh').each(function() {
var thisHeight = $(this).height();
allHeights.push(thisHeight);
});
var highestHeight = Math.max.apply(Math, allHeights);
$('.sh').height(highestHeight);
}
这是一个工作的 jsfiddle,尝试调整结果窗口的大小以查看它的工作情况。 https://jsfiddle.net/649n8dmc/
关于javascript - 调整大小时重新计算高度,视口(viewport) < 680 处为 "destroy script",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37787604/
我有两个类(class): parent 和 child child : belongs_to :parent 和 家长 has_many :children, :dependent => :dest
我有这个模型 class XmlImport ["text/xml"] end :event_import_records 条目正在被销毁。但是 :events 不是。 has_many throu
我定义了以下简单的管道: image: name: hashicorp/terraform:light entrypoint: - '/usr/bin/env' - 'PATH
我定义了以下简单的管道: image: name: hashicorp/terraform:light entrypoint: - '/usr/bin/env' - 'PATH
在我们的应用程序中,我们覆盖了 ActiveRecord destroy 方法,以便我们的记录不会被删除(因此用户可以取消删除)。像这样: def destroy self.is_deleted
我有一个笔记模型,具有以下关联 注意.rb has_many :note_categories, :dependent => :destroy has_many :categories, :throu
我是一名 Python 初学者。尝试制作一个新按钮来关闭窗口。我收到错误消息: Exception in Tkinter callback Traceback (most recent call la
我在我的应用程序中添加了评论功能,到目前为止一切正常,直到出现此错误。我所做的是添加了删除评论功能。当我启动服务器时一切正常,但在我单击“删除”按钮后问题出现了。 错误信息 undefined loc
Rails,def destroy,没有响应 destroy.js.erb 这是我的方法: # DELETE /Groups/1 # DELETE /Groups/1.xml def de
假设我有一个 MyClass 对象的集合 MyCollection。 Set MyCollection = Nothing 是否调用每个包含的对象的析构函数,或者我应该单独设置每个对象 = Nothi
我正在尝试使用 Node.js、Express 和 Mongodb 构建 REST API。我正在使用 mongodb npm 包连接到数据库,下面是我的 sever.js 文件代码 var expr
我有一个小问题,我有以下两个模型: class CriticalProcess :destroy has_many :roles, :through => :authorizations a
我正在使用 ng2-toastr 并收到以下错误 https://www.npmjs.com/package/ng2-toastr Attempt to use a destroyed view: d
基本信息: 系统: # cat /proc/version Linux version 3.10.0-514.2.2.el7.x86_64 (builder@kbuilder.dev.centos.o
一 点睛 destroy 用于销毁 ThreadGroup,该方法只是针对一个没有任何 active 线程的 group 进行一次 destroy 标记,调用该方法的直接结果是在父 group 中将自
我开始注意到 Scope::Guard 的一些奇怪之处。 . 如果我取消定义 $guard变量作为 sub 中的最后一个语句,守卫的 sub 得到 比我预期的要晚打电话。 如果我不取消它,或者如果我做
我正在构建一个提供打开和关闭它的服务的模式。该模式有一个控制关闭按钮的小 Controller ,以及进入模式内容的模板的 $compile。 那个模板就是一个组件,当然,那个组件有一个 Contro
一直在文件馆和网上寻找答案,但没有真正找到答案,只是零零碎碎。似乎有很多建议的帖子,但没有一个有答案。 我有一个使用范围的复杂指令:true。它实际上是我正在尝试为其编写清理代码的 ng-grid 最
给定以下 Delphi 代码,Foo 在 FormClose 上是 Free,但 TFoo.Destroy 是没有被调用 - 因此 Bar 没有被 Free'd,导致内存泄漏? 我是否在这里错过了一些
https://docs.angularjs.org/guide/directive By listening to this event, you can remove event listener
我是一名优秀的程序员,十分优秀!