2016-07-26 101 views
-2

我终于在手机,风景和肖像上工作过我的网站,但我仍然无法在平板电脑上工作!如何让我的网站在平板电脑上工作?

我用媒体查询,使在手机上我的网站的工作,这是我做的:

@media screen and (max-width: 1024px) { 
 
\t 
 
\t body{ 
 
\t \t position: relative; 
 
\t \t left: 100px; 
 
\t } 
 
\t .pintro{ 
 
\t \t position: relative; 
 
\t \t top: 180px; 
 
\t \t width: 500px; 
 
\t } 
 
\t .hintro{ 
 
\t \t position: relative; 
 
\t \t top: 180px; 
 
\t } 
 
\t 
 
    /* The rest of my code */ 
 
} 
 

 

 

 
@media screen and (max-width: 1024px) and (max-height: 400px) { 
 
\t body{ 
 
\t \t font-family: 'Noto Sans', sans-serif; 
 
\t \t background: url("nature-blur-tree-greenex.jpg") no-repeat center center fixed; 
 
\t \t width: 100%; \t 
 
\t \t max-width: 900px; 
 
\t \t margin: 0 auto; 
 
\t \t position: relative; 
 
\t \t right: 8%; 
 
\t } 
 
\t 
 
\t .pintro{ 
 
\t \t position: relative; 
 
\t \t line-height: 50px; \t \t 
 
\t \t left: -100px; 
 
\t } 
 

 
\t /* The rest of my code */ 
 
}

然后我想这样做,随着平板电脑,在这种形式:

@media only screen and (min-device-width: 768px){ 
 
\t .footer{ 
 
\t \t position: reltive; 
 
\t \t top: 1000px; 
 
\t } 
 
}

但是,这并没有奏效。如果有人向我提供媒体查询,我可以将其放入我的CSS以供我的网站使用平板电脑,我将不胜感激。

感谢。

+0

https://css-tricks.com/snippets/css/media-queries-for-standard-devices/ –

+0

你提的问题是非常广阔。有很多可能的答案。考虑根据您网站的内容管理您的断点:http://stackoverflow.com/q/8564752/3597276 –

+0

谢谢伊莎贝尔公司,您的链接非常有用,它的工作。 – Ned29

回答

0

尝试使用此codepen

/* 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 */ 
 
} 
 

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

 
/* Desktops and laptops ----------- */ 
 
@media only screen 
 
and (min-width : 1224px) { 
 
/* Styles */ 
 
} 
 

 
/* Large screens ----------- */ 
 
@media only screen 
 
and (min-width : 1824px) { 
 
/* Styles */ 
 
} 
 

 
/* iPhone 4 ----------- */ 
 
@media 
 
only screen and (-webkit-min-device-pixel-ratio : 1.5), 
 
only screen and (min-device-pixel-ratio : 1.5) { 
 
/* Styles */ 
 
} 
 
/* iPhone 6 landscape */ 
 
@media only screen and (min-device-width: 375px) 
 
    and (max-device-width: 667px) 
 
    and (orientation: landscape) 
 
    and (-webkit-min-device-pixel-ratio: 2) 
 
{ } 
 

 
/* iPhone 6 portrait */ 
 
@media only screen 
 
    and (min-device-width: 375px) 
 
    and (max-device-width: 667px) 
 
    and (orientation: portrait) 
 
    and (-webkit-min-device-pixel-ratio: 2) 
 
{ } 
 

 
/* iPhone 6 Plus landscape */ 
 
@media only screen 
 
    and (min-device-width: 414px) 
 
    and (max-device-width: 736px) 
 
    and (orientation: landscape) 
 
    and (-webkit-min-device-pixel-ratio: 3) 
 
{ } 
 

 
/* iPhone 6 Plus portrait */ 
 
@media only screen 
 
    and (min-device-width: 414px) 
 
    and (max-device-width: 736px) 
 
    and (orientation: portrait) 
 
    and (-webkit-min-device-pixel-ratio: 3) 
 
{ } 
 

 
/* iPhone 6 and 6 Plus */ 
 
@media only screen 
 
    and (max-device-width: 640px), 
 
    only screen and (max-device-width: 667px), 
 
    only screen and (max-width: 480px) 
 
{ } 
 

 
/* Apple Watch */ 
 
@media 
 
    (max-device-width: 42mm) 
 
    and (min-device-width: 38mm) 
 
{ }

+0

谢谢!这应该派上用场! – Ned29

+0

不客气,我还没有与90个网站的问题。 – mlegg

相关问题