【发布时间】:2019-09-11 00:12:48
【问题描述】:
我有这个网站:
www.kenyonglover.net
图片的代码在前面。
<div class="row centerdiv style_featured">
<div class="col-md-7 col-xs-7 col-ms-7">
<a href="https://bostonperfumery.com/shop?olsPage=products%2Fk-glovers-black-code" target="_blank"><img class="bottlefragranceshomeright img-responsive grayscale" src="images/fragrance/received_350849349195382_resized.jpeg" alt="" title="Click to purchase Kenyon Glover's Black Code Fragrance for Men"></a>
</div>
<div class="col-md-5 col-xs-7 col-ms-7">
<a href="https://bostonperfumery.com/shop?olsPage=products%2Fk-glovers-endless-love-for-women" target="_blank"><img class="bottlefragranceshomeleft img-responsive grayscale" src="images/fragrance/received_736852273421347_resized.jpeg" alt="" title="Click to purchase Kenyon Glover's Endless Love Fragrance for Women"></a>
</div>
</div>
该网站在大屏幕上很好,但是当它缩小到移动设备时,图像就会消失。
CSS:
.bottlefragrances {
width: 250px;
height: auto;
}
.bottlefragranceshomeleft {
margin-left: 125px !important;
width: 150px !important;
float: left !important;
}
.bottlefragranceshomeright {
margin-left: 100px !important;
width: 150px !important;
float: right !important;
}
/* Grayscale rollover */
.grayscale {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */
-webkit-transition: all .6s ease; /* Fade to color for Chrome and Safari */
-webkit-backface-visibility: hidden; /* Fix for transition flickering */
}
.grayscale:hover {
filter: none;
-webkit-filter: grayscale(0%);
}
.centerdiv {
margin-left: auto !important;
margin-right: auto !important;
}
我的目标是使图像更小并随着屏幕视口的变化而堆叠。
我需要一组媒体查询才能在我修改过的模板上进行这项工作。
更新:
所以我实施了建议的解决方案,但得到了这个......
图片不高。我从图像类中删除了 img-responsive ,认为这就是它。
更新二:
我明白了!
这是基于我投票支持的解决方案的解决方案。
在第一个下方添加了另一个媒体查询
@media (min-width: 320px) and (max-width: 767px) {
.introduction{
float: none;
position: relative;
background-image: url('http://www.kenyonglover.net/images/fragrance/DSC_0134-Hi%20Res_resized.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: top center;
padding: 20px;
}
.introduction > img{
display: none
}
.bottlefragranceshomeright, .bottlefragranceshomeleft {
margin: auto !important;
width: 150px !important;
float: none !important;
position: relative !important;
height: 145px !important;
}
.intro-content h1{
font-size: 28px;
}
.intro-content h2{
font-size: 17px
}
}
@media (min-width: 768px)and(max-width: 1440px) {
.introduction{
float: none;
position: relative;
background-image: url('http://www.kenyonglover.net/images/fragrance/DSC_0134-Hi%20Res_resized.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: top center;
padding: 20px;
}
.introduction > img{
display: none
}
.bottlefragranceshomeright, .bottlefragranceshomeleft {
margin: auto !important;
width: 150px !important;
float: none !important;
position: relative !important;
height: auto !important;
}
.intro-content h1{
font-size: 28px;
}
.intro-content h2{
font-size: 17px
}
}
并像这样调整图像的 CSS:
.bottlefragrances {
width: 250px;
height: auto;
}
.bottlefragranceshomeleft {
margin-left: 175px;
width: 150px !important;
float: left !important;
}
.bottlefragranceshomeright {
margin-left: 145px;
width: 150px !important;
float: right !important;
}
最后,HTML 是这样的......
<div class="row centerdiv style_featured">
<div class="col-md-6 col-xs-6 col-ms-7">
<a href="https://bostonperfumery.com/shop?olsPage=products%2Fk-glovers-black-code" target="_blank"><img class="bottlefragranceshomeright grayscale" src="images/fragrance/received_350849349195382_resized.jpeg" alt="" title="Click to purchase Kenyon Glover's Black Code Fragrance for Men"></a>
</div>
<div class="col-md-6 col-xs-6 col-ms-7">
<a href="https://bostonperfumery.com/shop?olsPage=products%2Fk-glovers-endless-love-for-women" target="_blank"><img class="bottlefragranceshomeleft grayscale" src="images/fragrance/received_736852273421347_resized.jpeg" alt="" title="Click to purchase Kenyon Glover's Endless Love Fragrance for Women"></a>
</div>
</div>
【问题讨论】:
-
更改.imgs父类的类:col-md-7 col-xs-7 col-ms-7 to col-md-7 col-xs-6 col-ms-7
标签: html css media-queries