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的時候 就不現(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的時候 就不顯示 展開全文。。。。。。
相關(guān)文章:
1. mysql - 這條聯(lián)合sql語句哪里錯了2. webpack - vuejs+java前后臺分離實(shí)現(xiàn)及部署問題3. docker容器呢SSH為什么連不通呢?4. docker鏡像push報(bào)錯5. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.6. python - 有什么好的可以收集貨幣基金的資源?7. docker start -a dockername 老是卡住,什么情況?8. docker網(wǎng)絡(luò)端口映射,沒有方便點(diǎn)的操作方法么?9. css3 - jquery div 翻轉(zhuǎn)?10. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題
