How to adjust html/css layout for instagram in-app browser?

江枫思渺然 提交于 2019-12-23 13:54:15

问题


I've been googling a lot, but found no clue for my problem. I have a tiny website (html/css only), that's looks nice on mobile Chrome. But on instagram in-app browser on Android 5.0 somethings goes wrong with paddings. Is there any way to deal with in-app browsers through media-queries or prefixes? So far I've found just nothing. Hope here someone could help me. Thanks in advance.

P.S. Sorry for my poor English, I am working on it.


回答1:


You can use JavaScript to detect the user-agent which includes Instagram and request a specific CSS for that case.

Example code:

<script>
var isInstagram = navigator.userAgent.match(/instagram/i);
if (isInstagram) {
  var head = document.querySelector('head');
  var link = document.createElement('link');
  link.rel = 'stylesheet';
  link.href = 'your-file-with-instagram-fixes.css';
  head.appendChild(link);
}
</script>


来源:https://stackoverflow.com/questions/40926277/how-to-adjust-html-css-layout-for-instagram-in-app-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!