【问题标题】:Responsive images resizing issue with bootstrap 3 and IE 10引导程序 3 和 IE 10 的响应式图像大小调整问题
【发布时间】:2015-04-27 19:19:01
【问题描述】:

我已经搜索了论坛,但似乎无法找到答案。我的图像在 FF、Chrome 和 IE 11 中都很好,但是在 IE 10 中,我的图像占据了整个页面,即使它们只有大约 300 像素宽。我正在使用带有 Joomla Purity III 模板的 bootstrap 3。我已经在 css 中看到了 hack:宽度:100% \9。我尝试删除 auto 的高度,但这似乎使我的图像消失了。这个问题的最佳/最简单的解决方案是什么?

 article img,
.article-intro img {
  display: block;
  width: 100% \9;
  max-width: 100%;
  height: auto;
}
.img-responsive,
.thumbnail > img,
.thumbnail a > img,
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
  display: block;
  max-width: 100%;
  width: 100% \9;
  background-color: #ffffff;
    border: 1px solid #dddddd;
    border-radius: 0;
   /* line-height: 1.42857;*/
    padding: 4px;
    transition: all 0.2s ease-in-out 0s;
}
.img-responsive-left {
    float: left;
    display: block;
    max-width: 100%;
    width: 100% \9;
    background-color: #ffffff;
    border: 1px solid #dddddd;
    border-radius: 0;
    line-height: 1.42857;
    padding: 4px;
    margin-right: 1em;
}
.img-responsive-right {
    float: right;
    display: block;
    max-width: 100%;
    width: 100% \9;
    background-color: #ffffff;
    border: 1px solid #dddddd;
    border-radius: 0;
    line-height: 1.42857;
    padding: 4px;
}
.img-left-borderless {
    float: left;
    display: block;
    width: 100% \9;
    max-width: 300px;
    background-color: #ffffff;
    border: none;
    line-height: 1.42857;
    padding: 4px;
}

.img-rounded {
  border-radius: 0;
}
.img-thumbnail {
  padding: 4px;
  line-height: 1.42857143;
  background-color: #ffffff;
  border: 1px solid #dddddd;
  border-radius: 0;
  display: inline-block;
  max-width: 100%;
  width: 100% \9;
  height: auto;
}

【问题讨论】:

  • 你的图片有固定宽度吗,如果没有,你可以使用引导程序自己的类,在图片上响应 img
  • jsg,我之前尝试过,但不幸的是它并没有阻止图像在 ie 10 中变大
  • 请注意,这是模板样式的问题,而不是 Bootstrap。

标签: css twitter-bootstrap internet-explorer-10


【解决方案1】:

最好的解决方案?只需删除width: 100% \9;,这是一个hack。

更强大的解决方案是确保 css 不会影响已设置尺寸的图像(就像使用图像编辑器插入图像时一样),例如:

/* Don't ignore `width` and/or `height` attributes if present. */
img[width],
img[height] {
    max-width: none;
    width: auto;
}

【讨论】:

  • 赛斯,感谢您的回复。这可能是一个愚蠢的问题,但我应该摆脱 max-width: 100%;在所有这些图像上?
  • 不,你可能不想要那个。这意味着它们不能在小于图片的屏幕上按比例缩小,从而导致图片“突破”您网站的一侧。
【解决方案2】:

尝试声明max-width: 300px,您可以通过在其末尾标记!important 来覆盖任何默认值。

max-width: 300px !important

如果这不起作用,那么查看更多代码以了解您的上下文会有所帮助。

【讨论】:

  • 唯一的问题是不是我所有的图像都是相同的大小。我可以提供一些代码,但不确定如何将其正确添加到此线程?
  • 您的代码前面必须有四个空格才能在堆栈溢出时显示为代码。这有点烦人,但确实有效。
  • 我回去编辑了我原来的问题。你能看到我添加的代码吗?谢谢
  • 我可以看到代码。如果不查看 html,就很难确切知道发生了什么。你有一个我可以看到确切情况的链接吗?这样我可能会更快地帮助你。
  • 嗨,巴里,非常感谢您的回复。我想我想通了(至少现在是这样)。我添加了宽度:自动而不是宽度:100%。不确定这是否会导致其他问题?我正在使用带有 Joomla 的 Purity III 模板的 Bootstrap 3,但我不确定要包含哪些 html?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-22
  • 1970-01-01
  • 2014-10-01
  • 1970-01-01
  • 2021-11-02
  • 2013-12-17
相关资源
最近更新 更多