[英]How to disable the scrollbars is width and height of body bigger than 1000px and 600px?
[英]jQuery's .height() function returns 0, when device width is less than 1000px
我有以下代碼片段來查找div的高度。
當在設備中查看時,返回1400px,寬度超過1000px。 這是我想在所有視口中工作的東西,但是當在寬度小於1000px的設備中查看時,它返回0。
var $slideheight=parseInt($('.swiper-slide.swiper-slide-active').height());
div具有.swiper-slide.swiper-slide-active
類和display:block
樣式屬性,還包含HTML內容。
我無法弄清楚為什么我的代碼在視口小於1000px寬度時返回0,而它適用於視口更多,超過1000px寬度。
盡量避免display:block
在絕對定位時display:block
,因為根據jQuery文檔,強烈建議不要在<style>
或<script>
標記上調用這些方法。 除了不好的做法外,結果也可能證明是不可靠的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.