2016-02-01 77 views
-1

我有一个html页面,必须具有特定的身体尺寸。它包含以下CSS:不需要的身体尺寸调整

<style> 
body{ 
    background-color:black; 
    padding-bottom:354px; 
    border:14px; 
    border-style:solid; 
    border-color:yellow; 
    } 
</style> 

每当我改变身体的文本与jQuery,身体的尺寸重新调整。有没有办法来防止这种情况?

编辑:全HTML

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="utf-8"> 
     <title>Lua console --- not ready</title> 
    </head> 
    <body onclick='clicked()' onload='loaded()'> 
<div class='console'> 
    <!--Anything in here will be overwritten--> 
</div> 
<!--import our main script--> 
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js'> </script> 
<!--We need css--> 
<!--But we also need a blank one--> 
<style id='console-styling'> 
</style> 
<!--Build the fake os--> 
<style> 
body{ 
    background-color:black; 
    padding-bottom:354px; 
    border:14px; 
    border-style:solid; 
    border-color:yellow; 
    color:white; 
} 
</style> 
<!--Add Lua and various listeners--> 
<script> 
    $('div').html('test') 
</script> 
    </body> 
</html> 
+1

需要看你的HTML/jQuery的为好,如果你想有一个很好的答案,最好的工作代码段 – LGSon

+0

新增的HTML内容。 –

+0

你的意思是“身体重新调整的大小”?究竟发生了什么? – JJJ

回答

0

是不是这样的,你希望它是什么?

$('div').html('test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>test<br>')
html, body{ 
 
    height:100vh; 
 
    margin: 0; 
 
} 
 
body{ 
 
    box-sizing: border-box; 
 
    background-color:black; 
 
    padding:177px; 
 
    border:14px; 
 
    border-style:solid; 
 
    border-color:yellow; 
 
    color:white; 
 
    
 
} 
 
.console { 
 
    background-color:gray; 
 
    height: 100%; 
 
}
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js'></script> 
 

 
<div class='console'> 
 
    <!--Anything in here will be overwritten--> 
 
</div>