简体   繁体   English

如何显示在桌面和移动视图上看起来都不错的横幅图像

[英]How to display banner images which look good on both desktop and mobile view

I have a progressive web app developed in reactjs and in this I am using banner images which look good on mobile view, but when I switch to laptop view the banner images look big.我有一个在 reactjs 中开发的渐进式 web 应用程序,在此我使用的横幅图像在移动视图中看起来不错,但是当我切换到笔记本电脑视图时,横幅图像看起来很大。

I tried to set the height property, but the image looks squeezed on laptop view.我试图设置高度属性,但图像在笔记本电脑视图中看起来被挤压了。 The CSS code for the same is pasted below下面粘贴了 CSS 代码

banner-container {
    padding: 20px;
    margin-top: 45px;

    .banner-img {
      max-width: 100%;
      height: auto;
    }

 }

@media (min-width: 767px) {
 .banner-container {
    padding: 20px;
    margin-top: 200px !important;
    max-width: 100%;

    .banner-img {
      width: 100%;
      height: auto;
      max-height: 300px;
    }

  }
}

What is the best way to display banner images which look good on both laptop and mobile view显示在笔记本电脑和移动设备视图上看起来都不错的横幅图像的最佳方式是什么

You can easily manage your banner image with this css property:您可以使用此 css 属性轻松管理您的横幅图片:

object-fit: contain

Or you can look into different values of object-fit in this doc:或者您可以在本文档中查看不同的 object-fit 值:

https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在移动和桌面视图中反应重用组件 - React reuse component in both mobile and desktop view 如何在移动设备上将我的 React 应用程序显示为桌面视图? - How to display my react application as desktop view on mobile? 如何在不实际最小化浏览器窗口的情况下在全屏桌面视图上显示react.js组件的CSS移动视图分辨率? - How to display the css mobile view resolution of a react.js component on a full screen desktop view without actually minimizing the browser window? 图像是移动响应的,但在桌面上没有响应 - Images are mobile responsive but are not responsive on Desktop Gatsby-Image:移动/桌面的不同图像? - Gatsby-Image: Different images for Mobile / Desktop? React:为移动设备和桌面加载两个不同的图像 - React: loading two different images for mobile and desktop 移动菜单效果扩展到桌面视图 - Mobile menu effect expands to desktop view react-native 对 web 开发和移动开发都有好处吗 - Is react-native good for both web development and mobile development React:对于Web应用程序,如何在不同视图的按钮上添加不同的功能(移动和桌面视图) - React: For a web application how to add different functionally on Buttons for different views(Mobile and Desktop View) SVG 线性渐变填充适用于桌面视图,但不适用于移动设备。 我怎样才能解决这个问题? - SVG linear-gradient fill works on desktop view but not on mobile. How can I fix this?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM