JS如何控制頁面高度來決定是否顯示查看更多
問題描述
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>sdfsd</title> <style type="text/css"> .demo{ width: 100%; height: 500px; overflow: hidden; position: relative; } .art_show{ position: absolute; z-index: 900; bottom: 0; margin: 0; padding: 0; width: 100%; height: 50px; border-bottom: 60px solid #f9f9f9; background-image: linear-gradient(hsla(0,0%,100%,0),#f9f9f9); color: #1c6bcc; text-align: center; line-height: 170px; } .pull{ position: absolute; width: 16px; left: 50%; top: 54px; margin-left: -8px; } </style> </head> <body> <div class="demo"> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <p>zfsdfsdfdxfsdfsdfsdfs</p> <div class="art_show"><img src="pull.png" class="pull" />展開全文</div> </div> <script src="jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(".art_show").click(function(){ $(".demo").css({"height":"auto"}); $(".art_show").css({"display":"none"}); }) </script> </body> </html>
如何通過JS控制 demo高度小于500的時(shí)候 就不現(xiàn)實(shí)展開全文。。。。。。
問題解答
回答1:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>sdfsd</title><style type="text/css">.demo{width: 100%;position: relative;}.art_show{position: absolute;display: none; z-index: 900; bottom: 0; margin: 0; padding: 0; width: 100%; height: 50px; border-bottom: 60px solid #f9f9f9; background-image: linear-gradient(hsla(0,0%,100%,0),#f9f9f9); color: #1c6bcc; text-align: center; line-height: 170px;cursor: pointer;}</style></head><body><div class="demo"><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p>zfsdfsdfdxfsdfsdfsdfs</p><p class="art_show">展開全文</p></div><script src="jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script><script type="text/javascript">var hei=$(".demo").height();$(".demo p:gt(13)").hide();if(hei>500){$(".art_show").show();}$(".art_show").click(function(){$(".demo p:gt(13)").show();$(this).hide();})</script></body></html>
回答2:補(bǔ)充:demo高度小于500px的時(shí)候 就不顯示 展開全文。。。。。。
相關(guān)文章:
1. angular.js - angularjs 使用鼠標(biāo)懸停時(shí),標(biāo)簽一直閃2. 一個(gè)走錯(cuò)路的23歲傻小子的提問3. c++ - win764位環(huán)境下,我用GCC為什么指針占8個(gè)字節(jié),而long是4個(gè)字節(jié)?4. html5 - HTML代碼中的文字亂碼是怎么回事?5. node.js - 函數(shù)getByName()中如何使得co執(zhí)行完后才return6. python - django 里自定義的 login 方法,如何使用 login_required()7. android - 安卓activity無法填充屏幕8. python 計(jì)算兩個(gè)時(shí)間相差的分鐘數(shù),超過一天時(shí)計(jì)算不對(duì)9. javascript - SuperSlide.js火狐不兼容怎么回事呢10. java - 安卓電視盒子取得了root權(quán)限但是不能安裝第三方應(yīng)用,請(qǐng)問該怎么辦?
