【问题标题】:Stacking images for the purpose of a media query出于媒体查询的目的堆叠图像
【发布时间】:2015-10-10 05:23:57
【问题描述】:

简单的问题,有一个我似乎无法弄清楚的简单答案。

我有 12 张 6 行 2 列形式的图像,当我的媒体查询中断到 240 像素宽时,我希望将它们格式化为 12 行 1 列。

这一定是一个非常简单的定位解决方案,我在 12 小时的工作服务器代码后完全错过了,但我找不到修复它的简单解决方案。

这是我的标记(所有 12 张图片都相同):

<div class="view view-first">
               <img src = "img/img1.jpg" alt="First Image">
               <div class="mask">
               <h2>Displayed 1st Image</h2>
               <p>Image example</p>
               <a href ="img1.html" class="info">Read More</a>
            </div>
        </div>

这是我对所有图像的标记:

.view {

   width: 300px;
   height: 200px;
   margin: 10px;
   float: left;
   border: 10px solid #fff;
   overflow: hidden;
   position: relative;
   text-align: center;
   -webkit-box-shadow: 1px 1px 2px #e6e6e6;
   -moz-box-shadow: 1px 1px 2px #e6e6e6;
   box-shadow: 1px 1px 2px #e6e6e6;
   cursor: default;
   background: #fff url(../img/bgimg.jpg) no-repeat center center;
}
.view .mask,.view .content {

   width: 300px;
   height: 200px;
   position: absolute;
   overflow: hidden;
   top: 0;
   left: 0;
}
.view img {
   display: block;
   position: relative;
}
.view h2 {
   text-transform: uppercase;
   color: #fff;
   text-align: center;
   position: relative;
   font-size: 17px;
   padding: 10px;
   background: rgba(0, 0, 0, 0.8);
   margin: 20px 0 0 0;
}
.view p {
   font-family: Georgia, serif;
   font-size: 16px;
   position: relative;
   color: #fff;
   text-shadow:3px 3px 5px #000;
   padding: 10px 20px 20px;
   text-align: center;
}
.view a.info {
   display: inline-block;
   text-decoration: none;
   padding: 7px 14px;
   background: #000;
   color: #fff;
   text-transform: uppercase;
   -webkit-box-shadow: 0 0 1px #000;
   -moz-box-shadow: 0 0 1px #000;
   box-shadow: 0 0 1px #000;
}
.view a.info: hover {
   -webkit-box-shadow: 0 0 5px #000;
   -moz-box-shadow: 0 0 5px #000;
   box-shadow: 0 0 5px #000;
}

我会显示媒体查询,但现在它只是调用和最大宽度规定哈哈。

感谢您的帮助;)

【问题讨论】:

  • 我不明白。测试您的标记,它会在应该的时候分成一列。另外,为了测试,我不得不粘贴你的图像代码 12 次。请您发布一个小提琴,并更好地描述您遇到的问题吗?

标签: html css media-queries


【解决方案1】:

如果您想使用媒体查询,您必须使用百分比作为宽度。这样,您的图像将在您调整浏览器大小时“缩放”。两行有 6 张图片意味着每张图片的宽度为 50%。请注意,您必须考虑帐户边距和填充。

您可以简单地从 xxxx 的大小输入您的媒体查询,将图像宽度设为 100%。

【讨论】:

    猜你喜欢
    • 2014-10-19
    • 2019-02-09
    • 2015-09-02
    • 1970-01-01
    • 2012-12-25
    • 1970-01-01
    • 2014-09-19
    • 2017-07-22
    • 2017-08-31
    相关资源
    最近更新 更多