通常最好为移动设备创建单独的 CSS 表...在这种情况下,您可以为您的 CSS 表做媒体选择器...这基本上是我在大多数情况下使用的
<!-- Desktop: Firefox , Chrome , IE -->
<link rel="stylesheet" media="all and (min-device-width:769px)"href="/CSS/Style.css"/>
<!-- Mobile devices: phone and ipad -->
<link rel="stylesheet" media="all and (max-device-width: 480px) and (orientation:portrait)"href="/CSS/phone_portrait_style.css" />
<link rel="stylesheet" media="all and (max-device-width: 640px) and (orientation:landscape)"href="/CSS/phone_landscape_style.css" />
<link rel="stylesheet" media="all and (device-width: 768px) and (device-height: 1024px) and (orientation:portrait)"href="/CSS/ipad_portrait_style.css" />
<link rel="stylesheet" media="all and (device-width: 768px) and (device-height: 1024px) and (orientation:landscape)"href="/CSS/ipad_landscape_style.css" />
然后,您可以在每张表格中创建要在您喜欢的任何特定设备上显示的 CSS。所以对于手机来说,按钮在纵向时可能是 240 像素,但在横向时是 320 像素。
请小心,因为按照您的方式,您的手机 CSS 只有在分辨率为恰好 600px 时才会显示。
您还应该注意,在您的移动肖像 css 表中,您应该有:
.button {
display: block;
width:100px;
background-image: url('http://examplepicture.com/blablabla');
}
在桌面css中:
.button {
display: none;
}
如果您不喜欢这种方法,我只是想为您针对不同手机/平板电脑方向的不同尺寸按钮获得奖励积分;)
手机人像css等
.button{
display: block;
width:200px;
background-image: url('http://examplepicture.com/blablabla');
}
还有 BAM!你得到了一些设备响应式 CSS 表单,它们会给爸爸妈妈留下深刻印象!