【发布时间】:2014-12-29 16:40:27
【问题描述】:
我正在尝试在fluidLayouts.css 文件中为流体布局设置图像宽度和高度,为此我正在通过dreamweaver cc 构建一个RWD 网站。
现在已获取图像宽度(以百分比为单位),我如何设置适合移动设备、标签和桌面的图像高度?我的意思是我应该以像素还是百分比来设置高度,这样才能适应手机、标签和桌面中的任何图像?
等待回复,谢谢。
【问题讨论】:
标签: css responsive-design
我正在尝试在fluidLayouts.css 文件中为流体布局设置图像宽度和高度,为此我正在通过dreamweaver cc 构建一个RWD 网站。
现在已获取图像宽度(以百分比为单位),我如何设置适合移动设备、标签和桌面的图像高度?我的意思是我应该以像素还是百分比来设置高度,这样才能适应手机、标签和桌面中的任何图像?
等待回复,谢谢。
【问题讨论】:
标签: css responsive-design
尝试以下标准设备的媒体查询 -
/* 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 */ }
您可以在其中根据设备编写 css 代码。
【讨论】:
height:auto;。只需设置宽度,高度将根据宽度自动考虑。
body { background: url(background-image.jpg) center center cover no-repeat fixed; }