简体   繁体   中英

How to get complete body width with inner elements padding?

I have this page which contains a table with 10-12 values , each table cell ( td ) has some padding(10px) . What is the best way to get the width of body including the width of this table containing the padded cells.

I tried using

window.innerWidth(true)
              element.containerWidth

In JS but it return me the width of body without the padding of inner elements.

and width:100% in CSS. Nothing Worked.

Edit: Even after using outerWidth(true) , it just takes in the viewable area and not the total area or the scrollable width . How can the scrollable width be taken ?

My code is

<script>
    window.onresize = displayWindowSize;
    window.onload = displayWindowSize;

    function displayWindowSize() {
        Width = $('body').outerWidth(true);
        Height = $('body').outerWidth(true);
        $('#header-bar').css('width',Width);
        $('#exec2').css('height',Height);
        $('#exec2').css('width', Width);
        $('#exec1').css('width', Width);
        $('#exec1').css('height',Height);
    };
</script>

Use outerWidth()

$('body').outerWidth()

Also you can get better idea of Width, OuterWidth, Inner by Click here

You can use .outerWidth()

In this scenario I would use $('body').outerWidth();

If you ever need the margin to be included you can use $('body').outerWidth(true); instead

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM