I have the following div style
.myDivStyle{
width: 0px;
position: absolute;
z-index: 1;
top: 0;
overflow-x: hidden;
}
which is applied to my div
<div id="myDiv" class="myDivStyle">...</div>
which looks perfect, and the following script returns 0px, again perfect.
alert($("#myDiv").css("width"));
But if I add a border to that style such as :
border: 1px solid #cccccc;
then there is a small 2px wide bod on the screen, and the js code above return a width of 2px.
How can I get the bordered div to not be visible on the screen and return a 0px width?
The show/hide of the div is controlled by javascript.
I know I can use display:none;
and turn it on again with the javascript but I want to see if it can be done by adjusting the style?
alert($("#myDiv").css("width"));
.myDivStyle {
width: 0px;
position: absolute;
z-index: 1;
top: 0;
overflow-x: hidden;
border: 1px solid #ccc;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="myDiv" class="myDivStyle">...</div>