【问题标题】:Responsive CSS: div too big响应式 CSS:div 太大
【发布时间】:2017-02-02 02:09:44
【问题描述】:

我正在尝试调整灯箱的大小。但是当我使用 max-width: 100% 时,图像对于 PC 的屏幕来说太大了 (img),对于手机来说太小了 (img)。而 max-width: 50%; 则相反(img1img2)。我该怎么办?

CSS:

/* The Modal (background) */
#galeria .modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    padding-top: 100px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
}

/* Modal Content */
#galeria .modal-content {
    margin: auto;
    padding: 20px;
    max-width: 50%;

}

HTML:

<!-- The Modal -->
<div id="myModal" class="modal">

  <!-- Modal content -->
  <div class="modal-content">

  <div class="close-button"><span class="close" id="close-sync">&times;</span></div>
    <div id="sync1" class="owl-carousel">
    <div class="item">
          <img src="assets/img/eventos/16-12-2016/01.JPG">
      </div>
    <div class="item">
          <img src="assets/img/eventos/16-12-2016/02.JPG">
      </div>
    </div>

    <div id="sync2" class="owl-carousel">
      <div class="item">
          <img src="assets/img/eventos/16-12-2016/01.JPG">
      </div>
    </div>

  </div>

</div>

【问题讨论】:

  • 有趣的公司名称:)
  • 使用媒体查询怎么样?
  • 这是一个葡萄牙语名称:Fundação Assistencial da Paraíba = Paraiba 的援助基金会。帕拉伊巴是巴西的一个州。

标签: javascript jquery html css lightbox


【解决方案1】:

你可以试试media queries:

#galeria .modal-content {
    margin: auto;
    padding: 20px;
}
/* phone screen width */
@media screen and (max-width: 600px) {
    #galeria .modal-content {
        max-width: 100%;
    }
}
/* greater than phone width */
@media screen and (min-width: 601px) {
    #galeria .modal-content {
        max-width: 50%;
    }
}

【讨论】:

  • 效果很好,我将阅读有关媒体查询的更多信息。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-24
  • 2014-08-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-24
  • 2020-01-03
相关资源
最近更新 更多