css - 在响应中隐藏图像?

标签 css twitter-bootstrap

我是 bootstrap 编码和 CSS 的新手 我遇到了一个问题,在桌面版本中我需要一张图片,但在移动版本中我需要显示第二张图片并且第一张图片应该隐藏。

<div class="col-md-9" style="padding: 0px;">
    <img src="images/Trinity-Garden-landing-Page-1.jpg" width="1350px" />
    <img src="images/Trinity-Garden-landing-Page-4.jpg" width="1350px" />
</div>

需要帮助。

最佳答案

请执行此代码。

您可以根据需要更改媒体查询中的最大宽度。另请展开代码段以根据设备检查隐藏和显示图像。 我希望它对你有用。

<style>
.image_section img{
    display: block;
}

@media (max-width:640px){
    .image_section img:first-child{
        display:none;
    }
}
</style>


<div class="col-md-9 image_section" style="padding: 0px;">
    <img src="images/Trinity-Garden-landing-Page-1.jpg" />
    <img src="images/Trinity-Garden-landing-Page-4.jpg" />
</div>

关于css - 在响应中隐藏图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43533942/

相关文章:

html - DIV间距的困难

css - 带有两行文本的导航栏品牌,垂直居中

javascript - 下拉菜单不会保持打开状态 bootstrap 4

css - 为我的主页设置一个与 rails 站点的其余部分不同的导航栏的最佳方法是什么?

javascript - jQuery 单击进入选择引导搜索不工作

javascript - Glyphicon 日历未打开

javascript - 在 Twitter Bootstrap 中使用输入/按钮时我们需要这个吗?

html - 在其他设备上查看时,Bootstrap 导航栏没有响应地对齐

html - 在行中垂直对齐 img - twitter bootstrap

javascript - 如何调用多个弹出窗口?