【】H5 DIV height changes to 0 problem_html/css_WEB-ITnose
WBOY
Release: 2016-06-24 11:47:16
Original
1666 people have browsed it
The HTML code is as follows. If the in the first line is removed, the DIV marked in red below can be displayed. If you add in the first line, the height of the red DIV will become 0px. I originally wanted to set the height via percentage. But this problem occurred. . . Can any hero help me take a look? Thanks!
< ) function mito( ) { var arrData = [{ "usericon" : "usericon-default", "username" : "Aimee", "usergender" : "F", "date " : "2-28", "title" : "This is the main text. If it is too long, it needs to be truncated. ", "replynum" : "100", "supportnum" : "9999" }, { " : "M", "date" : "2 -28", "title": "This is the main text. If it is too long, it needs to be truncated. Hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha", "replynum": "100", "supportnum " : "9999 " "usergender" : "M", "date " : "2-28", "title" : "This is the main text. If it is too long, it needs to be truncated. Hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha" "usericon" : "usericon-default", "username" : "Daniel", "usergender" : "M", "date" : "2-28", "title" : "这是正文,如果超长,需要截断。哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈", "replynum" : "100", "supportnum" : "9999+" }];
var tmpl = '
' + '
' + ' ' + '
${username}
' + '
${usergender}
' + '
${date}
' + '
' + '
${title}
' + '
Arean' + '
' + '
' + ' ' + '
' + '
' + '
' + '
' + '
评论图标
' + '
评论数量${replynum}
' + '
赞
' + '
${supportnum}
' + '
回复图标
' + '
发射弹幕
' + '
' + '
'; var s = appcan.tempRenderList(tmpl, arrData, appcan.getObjLength(arrData)); setAttribute("class" , "ub ub-ver uinn-m uof"); d.innerHTML = s; $('#mito')[0].appendChild(d); } < /script> After that, the html tag will be automatically added with a height. The height is set according to the browser height. When you add , the height will not be added to the html tag, and all your internal divs will be It is a percentage control. When the html tag does not have a height attached, the internal div height loses reference, so the height becomes 0. If you need to solve this problem, just add the height to the body or html
After some debugging, I found that it was caused by the second layer div in the Body:
not setting height: 100%. Adding it solved the problem. Thanks!
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn