@ 미디어 최소 너비 및 최대 너비
이 @media
설정이 있습니다.
HTML :
<head>
<meta name="viewport" content="width=device-width, user-scalable=no" />
</head>
CSS :
@media screen and (min-width: 769px) {
/* STYLES HERE */
}
@media screen and (min-device-width: 481px) and (max-device-width: 768px) {
/* STYLES HERE */
}
@media only screen and (max-device-width: 480px) {
/* STYLES HERE */
}
이 설정을 사용하면 iPhone에서 작동하지만 브라우저에서는 작동하지 않습니다.
내가 이미 device
메타에 있었기 때문에 그럴 수 max-width:480px
있습니까?
가장 좋은 방법은 5.5, 6, 7 및 8을 포함한 이전 브라우저와 같이 이전 브라우저에 기본 CSS를 작성하는 것입니다. @media를 읽을 수 없습니다. @media를 사용하면 다음과 같이 사용합니다.
<style type="text/css">
/* default styles here for older browsers.
I tend to go for a 600px - 960px width max but using percentages
*/
@media only screen and (min-width: 960px) {
/* styles for browsers larger than 960px; */
}
@media only screen and (min-width: 1440px) {
/* styles for browsers larger than 1440px; */
}
@media only screen and (min-width: 2000px) {
/* for sumo sized (mac) screens */
}
@media only screen and (max-device-width: 480px) {
/* styles for mobile browsers smaller than 480px; (iPhone) */
}
@media only screen and (device-width: 768px) {
/* default iPad screens */
}
/* different techniques for iPad screening */
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
/* For portrait layouts only */
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
/* For landscape layouts only */
}
</style>
그러나 @media로 원하는 모든 것을 할 수 있습니다. 이것은 모든 브라우저에 대한 스타일을 만들 때 내가 찾은 최고의 예입니다.
또한! 인쇄 가능성을 찾고 있다면@media print{}
근본적인 문제는 max-device-width
vs old를 사용하고 max-width
있습니다.
Using the "device" keyword targets physical dimension of the screen, not the width of the browser window.
For example:
@media only screen and (max-device-width: 480px) {
/* STYLES HERE for DEVICES with physical max-screen width of 480px */
}
Versus
@media only screen and (max-width: 480px) {
/* STYLES HERE for BROWSER WINDOWS with a max-width of 480px.
This will work on desktops when the window is narrowed. */
}
The correct value for the content
attribute should include initial-scale
instead:
<meta name="viewport" content="width=device-width, initial-scale=1">
^^^^^^^^^^^^^^^
If website on small devices behavior like desktop screen then you have to put this meta tag into header before
<meta name="viewport" content="width=device-width, initial-scale=1">
For media queries you can set this as
this will cover your all mobile/cellphone widths
@media only screen and (min-width: 200px) and (max-width: 767px) {
//Put your CSS here for 400px to 600px width devices (cover all mobile portrait width //
}
For iPad and iPad pro you have to use
@media only screen and (min-width: 768px) and (max-width: 1024px) {
//Put your CSS here for 768px to 1024px width devices(covers all iPad portrait width //
}
If you want to add css for Landscape mode you can add this
and (orientation : landscape)
@media only screen and (min-width: 200px) and (max-width: 767px) and (orientation : landscape) {
//Put your CSS here for 400px to 600px width devices (cover all mobile landscape width //
}
참고URL : https://stackoverflow.com/questions/13550541/media-min-width-max-width
'Programing' 카테고리의 다른 글
grep이 'No such file or directory'오류를 출력하지 않게하려면 어떻게해야합니까? (0) | 2020.05.09 |
---|---|
언제 ASP.NET MVC에서 비동기 컨트롤러를 사용해야합니까? (0) | 2020.05.09 |
Java VM이 몇 개의 스레드를 지원할 수 있습니까? (0) | 2020.05.09 |
C void 인수“void foo (void)”를 사용하거나“void foo ()”를 사용하지 않는 것이 더 낫습니까? (0) | 2020.05.09 |
Swift에서 사전을 반복 (0) | 2020.05.09 |