Default body margin, I did not set, but it has a default value of 8px, how can I get this value?
<style type="text/css">
fieldset {
border: solid 1px orange
}
.label {
font-family: Arial;
font-size: 12px;
font-weight: bold
}
.groupName {
font-family: Segoe UI;
font-size: 16px;
color: Gray
}
</style>
<script type="text/javascript" src="libs/json2.js"></script>
<script type="text/javascript" src="libs/jquery.js"></script>
<script type="text/javascript" src="libs/sap.common.globalization.js"></script>
<script type="text/javascript" src="libs/sap.riv.base.js" base-url="modules/"></script>
<script type="text/javascript" src="modules/main.js"></script>
<script type="text/javascript" src="libs/sap.riv.themes.js"></script>
</head>
<body>
<div id="chart" style="width: 600px; height: 400px; background-color: #ffffff"><div id="0" style="position: absolute; font-size: 10px; box-sizing: border-box; overflow-x: visible; overflow-y: visible; left: 8px; top: 8px; width: 600px; height: 400px; ">`
In chrome, I see
body{
display:block;
margin: 8px;
}
I am using document.getElementsByTagName ('body'). style, but I get nothing.
my first div is located at the top and left: 8px html body.
But it has margin, how can I get this default value?
You can see the following link:
http://javascript.info/tutorial/styles-and-classes-getcomputedstyle
Check the value of the field ( http://jsfiddle.net/eMnBL/6/ ):
var computedStyle = window.getComputedStyle ? getComputedStyle(document.body, null) : document.body.currentStyle;
alert(computedStyle['marginTop']);
document.getElementsByTagName('body')returns an array of success.
To get rid of the field in the body, use regular css
body{
margin: 0;
}
EDIT: , quirksmode
function getStyle(el,styleProp)
{
if (el.currentStyle)
var y = el.currentStyle[styleProp];
else if (document.defaultView && document.defaultView.getComputedStyle)
var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
return y;
}