简体   繁体   English

iPad和移动设备的媒体查询

[英]Media Query for iPads and Mobile

I am designing a personal page . 我正在设计个人页面 I've been using Chrome Canary to make sure all my media queries were in line. 我一直在使用Chrome Canary来确保所有媒体查询都符合要求。 Everything shows really well in Canary and all the desired device modes work properly. 在Canary中一切都显示得非常好,并且所有所需的设备模式都可以正常工作。 However, when I open my page on an iPad, iPhone, or Blackberry it doesn't display correctly. 但是,当我在iPad,iPhone或Blackberry上打开页面时,页面无法正确显示。 For mobile phones, everything below the Featured Work section does not display. 对于手机,“特色工作”部分下方的所有内容均不会显示。 For iPads, everything after "Featured Work" displays down a single column which spans 33.33% of the page width. 对于iPad,“精选作品”之后的所有内容均向下显示一列,占页面宽度的33.33%。 I am not sure why. 我不知道为什么。

The TL;DR of my question is: What am I missing in my HTML or CSS file that, when added, will help my pages display properly on iPads and iPhones?? 我的问题的TL; DR是:我的HTML或CSS文件中缺少什么,添加这些文件将有助于我的页面在iPad和iPhone上正确显示?

In head of my HTML file, I use: 在我的HTML文件的开头,我使用:

Initially, the only media query that I had was: 最初,我仅有的媒体查询是:

@media only screen and (max-width: 767px) @media only屏幕和(最大宽度:767px)

When I saw that didn't initially work on iPad and iPhone I added 当我看到最初无法在iPad和iPhone上运行时,我添加了

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) { @仅限纯媒体屏幕,(最小设备宽度:768像素)和(最大设备宽度:1024像素){

@media only screen and (min-device-width : 320px) and (max-device-width : 568px) { @仅限纯媒体屏幕,(最小设备宽度:320像素)和(最大设备宽度:568像素){

When working within Chrome, I felt everything displayed properly until the images got to small (800px or so). 在Chrome浏览器中工作时,我觉得一切正常显示,直到图像变小(大约800像素)为止。 There were some font size issues as the page got smaller. 随着页面变小,存在一些字体大小问题。 I restructure the bottom part of the page (below Featured Work) and do that using the "@media only screen and (max-width: 767px)" query. 我调整了页面的底部结构(在Featured Work下面),并使用“仅@media屏幕和(最大宽度:767px)”查询来完成。

I'm really stumped as to why everything is displaying oddly on my iPad. 我真的很困惑为什么iPad上的所有内容显示都不正常。 I've tried different display: (flex, inline, box), to address the iPad issue. 我尝试了不同的显示方式:(flex,inline,box),以解决iPad问题。 All were to no avail. 所有人都无济于事。

For the iPhone issue, I've tried copying everything under the "@media only screen and (max-width: 767px)" and put it under the "@media only screen and (min-device-width : 320px) and (max-device-width : 568px)" query. 对于iPhone问题,我尝试将所有内容复制到“ @media only屏幕和(max-width:767px)”下,并将其放在“ @media only屏幕和(min-device-width:320px)和(max -device-width:568px)”查询。 But that didn't work. 但这没有用。

I haven't attempted re-writing my entire CSS file. 我没有尝试重写整个CSS文件。 My thoughts are that since all these devices have predefined widths that I could adjust all my div widths to actual px values instead of percentages. 我的想法是,由于所有这些设备都具有预定义的宽度,因此我可以将所有div宽度调整为实际的px值,而不是百分比。 However, I feel that is unneccessary work. 但是,我觉得这是不必要的工作。

Try this: Edited to accommodate for the margins... 尝试以下操作:编辑以适应边距...

.projectdeets {
    width: 100%;
    height: 30%;
    display: inline-block;
    max-height: 300px;
}
.project {
    width: calc(33.33% - 6px);
    height: 100%;
    margin: 0px 3px 0px 3px;
    float:left;
}

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

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