简体   繁体   English

如何使我的网站宽度完全适合 iphone 5?

[英]How can I make my website width fit fully on iphone 5?

I am working on a new site for my photography hobby.我正在为我的摄影爱好开发一个新网站。 the ad is faspix.com I have got it to fit onto laptop/desktops how I would like but I am having an issue with making the width fit onto my iPhone when I load the page on iPhone the height is there fully but the width only shows about half from left to right then I have to scroll right to see the rest of the width... I have tried a bunch of different media queries but nothing has really solved the issue for example when I switched the site_content to max width 100 it just shrunk the container on the iPhone.广告是 faspix.com 我已经让它适合我想要的笔记本电脑/台式机,但是当我在 iPhone 上加载页面时,我遇到了让宽度适合我的 iPhone 的问题,高度在那里,但只有宽度从左到右显示大约一半然后我必须向右滚动才能看到其余的宽度......我尝试了一堆不同的媒体查询,但没有真正解决这个问题,例如当我将 site_content 切换到最大宽度 100 时它只是缩小了 iPhone 上的容器。 Can someone help me get this width issue fixed on the iPhone?有人可以帮我解决 iPhone 上的这个宽度问题吗? Thanks谢谢

CSS: CSS:

media (max-device-width: 1024px) { /*IPad portrait AND netbooks, AND anything with smaller screen*/ /*make the design flexible if possible */ /*Structure your code thinking about all devices that go below*/ } 

@media (max-device-width: 640px) { /*Iphone portrait and smaller*/ } 

media (max-device-width: 540px) { /*Smaller and smaller...*/ } 

media (max-device-width: 320px) { /*IPhone portrait and smaller. You can probably stop on 320px*/ } 

将此代码添加到标题中!

<meta http-equiv="Content-type" name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">

Since there is no Code, just a shot in the dark.由于没有代码,只是在黑暗中拍摄。 Add添加

<meta name="viewport" content="width=device-width; initial-scale=1.0" />

to the head of your HTML.到您的 HTML 的头部。

Judging from what you have copied onto here, your media queries seem to be incorrect, here are some example queires, as answered on this question...从您复制到此处的内容来看,您的媒体查询似乎不正确,这里有一些示例查询,如在问题上的回答...

/* Smartphones (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) {
  /* Styles */
}

/* Smartphones (landscape) ----------- */
@media only screen 
and (min-width : 321px) {
  /* Styles */
}

/* Smartphones (portrait) ----------- */
@media only screen 
and (max-width : 320px) {
  /* Styles */
}

/* iPads (portrait and landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) {
  /* Styles */
}

/* iPads (landscape) ----------- */
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {
  /* Styles */
}

Obviously add the styles as per requirements, and change media query sizes as needed!显然,根据要求添加样式,并根据需要更改媒体查询大小!

For future reference, CSS Tricks has a good article for you to read up on Media Queries.为了将来参考, CSS Tricks有一篇很好的文章供您阅读媒体查询。 Another thing you need to consider will be browser compatibility, as IE8 and before doesn't support this, as stated here你需要考虑的将是浏览器的兼容性,因为IE8和之前的另一件事情并不支持这一点,因为说这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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