帖子中的查看全部 折叠内容怎么搞的?

@Ta 2017-09-06 3195点击
@?
回复列表(6|隐藏机器人聊天)
  • @Ta / 2017-09-06 / /
    被禁言
    用户被禁言,发言自动屏蔽。
  • @Ta / 2017-09-06 / /
    @无期徒刑,大佬,css都能实现?
  • @Ta / 2017-09-06 / /

    @大尨,弄个框框把内容框住,超过一定字符折叠
    小米5s Plus(拉丝深灰)

  • @Ta / 2017-09-06 / /
    我呢第一理解:
    在林子里,你发帖篇幅大会自动折叠的,不用怎么搞,
  • @Ta / 2017-09-06 / /
    <script>
    	function foldFold(floor) {
    		var content = document.getElementById('floor_content_' + floor);
    		var foldBar = document.getElementById('floor_fold_bar_' + floor);
    		
    		content.style.maxHeight = '768px';
    		foldBar.innerHTML = '<a id="floor_expand_' + floor +
    				'" href="#" onclick="foldExpand(' + floor + ');return false">查看全部</a>';
    	}
    	
    	function foldExpand(floor) {
    		var content = document.getElementById('floor_content_' + floor);
    		var foldBar = document.getElementById('floor_fold_bar_' + floor);
    		
    		content.style.maxHeight = '';
    		foldBar.innerHTML = '<a id="floor_fold_' + floor +
    				'" href="#" onclick="foldFold(' + floor + ');return false">折叠内容</a>';
    	}
    	
    	function foldFloorInit(floor) {
    		var content = document.getElementById('floor_content_' + floor);
    		var height = content.offsetHeight;
    		
    		if (height > 768) {
    			var foldBar = document.getElementById('floor_fold_bar_' + floor);
    			
    			foldBar.style.borderTop = '1px solid #BED8EA';
    			foldBar.style.borderBottom = '1px solid #BED8EA';
    			foldBar.style.height = '24px';
    			foldBar.style.textAlign = 'center';
    			
    			foldFold(floor);
    		}
    	}
    	
    	function foldFloorOnload(floorSize) {
    		var i;
    		
    		for (i=0; i<floorSize; i++) {
    			foldFloorInit(i);
    		}
    	}
    </script>
    <script>
        function atAdd(uid,that) {
            that.style.color = "#FFA500";
            var nr = document.getElementById("content");
            nr.value += "@"+uid+",";
        }
    </script>
    		<div class="floor_content" id="floor_content_0">
    [文章正文.....]
    </div>
    		<div class="floor_fold_bar" id="floor_fold_bar_0"></div>
    		<script>foldFloorInit(0)</script>
    @大尨,这是老虎的源码,自行研究吧
  • @Ta / 2017-09-06 / /
    Overview : hidden; 
添加新回复
回复需要登录