首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >网站的自适应布局

网站的自适应布局
EN

Stack Overflow用户
提问于 2018-02-10 22:03:41
回答 1查看 35关注 0票数 2

我为我糟糕的英语提前道歉,如果不是这样的话))。

你好,我需要帮助,如何移动块时,缩放为手机。

目前,如果缩小屏幕,它们只是略微缩小。

以下是在扩展时应该如何迁移它们的example

请提前谢谢您的帮助。

以下是该网站的区块布局代码:

代码语言:javascript
复制
.section {
    position: absolute;
    z-index: 0;
    width: 50%;
    height: 50%;
    overflow: hidden;
    -webkit-transform: scale(1);
            transform: scale(1);
    will-change: transform;
    -webkit-transition-property: all;
    transition-property: all;
    -webkit-transition-duration: 300ms;
            transition-duration: 300ms;
    -webkit-transition-timing-function: ease-in-out;
            transition-timing-function: ease-in-out;
  }
  .section:first-child {
    top: 0;
    left: 0;
    background: #F06060;
  }
  .section:nth-child(2) {
    top: 0;
    left: 50%;
    background: #FA987D;
  }
  .section:nth-child(3) {
    top: 50%;
    left: 0;
    background: #72CCA7;
  }
  .section:nth-child(4) {
    top: 50%;
    left: 50%;
    background: #10A296;
  }
  .section.is-expanded {
    top: 0;
    left: 0;
    z-index: 1000;
    width: 100%;
    height: 100%;
  }
  .has-expanded-item .section:not(.is-expanded) {
    -webkit-transform: scale(0);
            transform: scale(0);
    opacity: 0;
  }
  
  .section.is-expanded {
    visibility: visible;
    opacity: 1;
    -webkit-transition: opacity 200ms linear 300ms;
    transition: opacity 200ms linear 300ms;
  }
  .demo-box {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    height: 100%;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    color: #fff;
    font-size: 2rem;
    font-weight: 300;
  }
代码语言:javascript
复制
<main class="main">
  <section class="section">
    <div class="demo-box">Section 1</div>
  </section>
  <section class="section">
    <div class="demo-box">Section 2</div>
  </section>
  <section class="section">
    <div class="demo-box">Section 3</div>
  </section>
  <section class="section">
    <div class="demo-box">Section 4</div>
  </section>
</main>

EN

回答 1

Stack Overflow用户

发布于 2018-02-10 22:16:00

代码语言:javascript
复制
@media only screen and (max-width:480)
{  
   .section {
        width: 100%;
        height: 50%;
        float:left;
    }
}

试试这个,我觉得很有用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48721599

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档