【问题标题】:Editing fluidLayouts.css in dreamweaver cc for image width and height在dreamweaver cc 中编辑fluidLayouts.css 以获取图像宽度和高度
【发布时间】:2014-12-29 16:40:27
【问题描述】:

我正在尝试在fluidLayouts.css 文件中为流体布局设置图像宽度和高度,为此我正在通过dreamweaver cc 构建一个RWD 网站。

现在已获取图像宽度(以百分比为单位),我如何设置适合移动设备、标签和桌面的图像高度?我的意思是我应该以像素还是百分比来设置高度,这样才能适应手机、标签和桌面中的任何图像?

等待回复,谢谢。

【问题讨论】:

    标签: css responsive-design


    【解决方案1】:

    尝试以下标准设备的媒体查询 -

     /* 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 代码。

    【讨论】:

    • 但是任何图像的“高度”呢?我该如何显示?
    • @Sharath-designer 不需要设置高度,你可以设置height:auto;。只需设置宽度,高度将根据宽度自动考虑。
    • Suthar:我忘了提到我正在尝试为背景图像设置高度。我猜身高:自动;不会为这个工作....任何其他方式?我什至尝试过: background-size: 100% 100%;虽然高度挤压。
    • 试试这个 - body { background: url(background-image.jpg) center center cover no-repeat fixed; }
    猜你喜欢
    • 2010-11-18
    • 1970-01-01
    • 2017-05-23
    • 2011-11-26
    • 1970-01-01
    • 1970-01-01
    • 2012-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多