html - 使大图像响应?

标签 html wordpress css wordpress-theming

我正在使用我正在编辑的 wordpress 主题(编辑 CSS)为桌面和移动用户制作网站。我的问题是正面图像很大,当低分辨率用户(即手机)连接网站时,图像会调整大小,只显示一小部分。这是解释我的问题的屏幕截图:

这是桌面用户访问的正常网站:

Desktop user

当用户使用小分辨率连接网站(即手机)时,网站会缩小

User on mobile phone

如您所见,图像现在看起来很糟糕。当分辨率低到整个图像适合该屏幕时,是否有缩小图像的方法?

这是我用来显示这张图片的 CSS: 这是 DIV 和一些段落的容器

* =Featured Content
-------------------------------------------------------------- */

#featured {
 -moz-border-radius: 4px;
  -webkit-border-radius: 4px;
  background-color: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 40px;
  padding-bottom: 40px;
  width: 99.893617021277%;
}

#featured p {
  font-size: 18px;
  font-weight: 200;
  line-height: 27px;
  color: #8B0000;
padding-top:250px;
padding-left:50px;
  text-align: left;
width:100%
}
#featured p1 {
  font-size: 18px;
  font-weight: 200;
  line-height: 27px;
  font-style:italic;
  color: #8B0000;
padding-top:50px;
padding-left:50px;
  text-align: left;
width:100%;

}

#featured-image {
  margin: 40px 0 0 0;
}

#featured-image .fluid-width-video-wrapper {
  margin-left: -20px;
}

.featured-image img {
  margin-top: 44px;
}

这是图像类:

    .col-940new {
  width: 100%;
  height:460px;
  background: url('uploads/19377249_ml-1024x6651.jpg');
}

这是用于此元素的 HTML

<div id="featured" class="grid col-940new">
        <div class="grid col-460">

            <h1 class="featured-title">
                            </h1>

            <h2 class="featured-subtitle">
                            </h2>

            <p>


            </p>



        </div><!-- end of .col-460 -->

        <div id="featured-image" class="grid col-460 fit">



        </div><!-- end of #featured-image --> 

    </div><!-- end of #featured -->

编辑:

在应用下面评论的一些方法后,我设法解决了问题,但现在当用户通过手机连接到网站时,我想删除一个“空白区域”。

代码相同,只是添加了这一行:

  background-size: 100% auto;

User view from mobile phone

最佳答案

因为它是背景图片,请将其添加到您的 CSS

演示 jsFiddle

.col-940new {
  width: 100%;
  height:460px;
  background-image:url('uploads/19377249_ml-1024x6651.jpg');
  background-repeat:no-repeat;
  background-size:contain;
  background-position:center;
}

关于html - 使大图像响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18428800/

相关文章:

javascript - 如何使用 jquery 获取以前的标签 (td) 子属性值?

html - 一些 Unicode 字符在 Kindle 上不显示

html - 选择嵌套在 div 层中的标签

php - 如何以编程方式更改 Wordpress 中的菜单?

css - 如何用 React 覆盖默认的 MaterialUI 样式?

html - 浏览器自动设置内容div的高度

javascript - 如何使用 Javascript 隐藏和显示基于特定 div 类基的多个 div?

php - 将 woocommerce 产品库缩略图显示在一行上作为 slider

wordpress - 重力形式上的js错误

css - 网站在 Safari 中完全崩溃