[英]CSS Styling for iOS Specific Device - not working
Hi I am having a major issue with the load of my website on iPhone devices, both safari and google chrome browsers.嗨,我的网站在 iPhone 设备(safari 和 google chrome 浏览器)上的负载存在重大问题。 I am trying to hide the element causing the issue but my Javascript or CSS code does not seem to be doing anything.
我试图隐藏导致问题的元素,但我的 Javascript 或 CSS 代码似乎没有做任何事情。
This is my Javascript code to detect the iPhone这是我的 Javascript 代码来检测 iPhone
<script>
if(navigator.userAgent.match(/iPhone/)) {
$('html').addClass('iphone');
}
</script>
and my CSS Class is just.iphone.banner-one {display: none;}而我的 CSS Class 是 just.iphone.banner-one {display: none;}
Could anyone help me with what I am doing wrong or a better way to fix it?任何人都可以帮助我解决我做错了什么或更好的解决方法吗? I do NOT want size specific CSS codes as I would like the element to still show up on android/windows devices.
我不希望特定尺寸的 CSS 代码,因为我希望该元素仍显示在 android/windows 设备上。
Maybe try:也许尝试:
<script>
if(navigator.userAgent.match(/iPhone/)) {
document.getElementsByClassName("banner-one")[0].style.display = "none";
}
</script>
or或者
<script>
if(navigator.userAgent.match(/iPhone/)) {
document.getElementsByClassName("banner-one")[0].remove();
}
</script>
or或者
<script>
if(navigator.userAgent.match(/iPhone/)) {
document.querySelector("body > div:nth-child(2) > section:nth-child(1) > img:nth-child(9)").style.display = "none";
}
</script>
or或者
<script>
if(navigator.userAgent.match(/iPhone/)) {
document.querySelector("body > div:nth-child(2) > section:nth-child(1) > img:nth-child(9)").remove();
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.