javascript - $(element).width() reports differently values on Safari mobile -


i'm using script total width of horizontal div:

$(document).ready(function(){    $('.portfolio li').each(function(index) {        totalwidthportfolio += parseint($(this).width(), 10) + 12;    });     $('.portfolio').css({        'width' : totalwidthportfolio ,        'visibility' : 'visible'    }); }); 

the problem on desktop, script returned 23406 , on mobile (safari , chrome), returned 22522.

i tried outerwidth(true) result same.

here css:

.portfolio{     margin: 0;     padding: 0;     list-style-type: none;     position: absolute;     top: 50%;     transform: translatey(-50%);     visibility: hidden; }  li{     float: left;     padding-right: 12px;     display: block;     box-sizing: border-box; }  li img{     display: block;     max-width: 100%;     height: auto; } 

update

the problems occurs on portrait mode

the value returned depends how browser parse yours li element. try add display: block properties on css


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -