• 请不要在回答技术问题时复制粘贴 AI 生成的内容
jazdelu
V2EX  ›  程序员

问一个低级的前端问题,怎么样让屏幕变小后出现滚轮,而不是内部元素变形?

  •  
  •   jazdelu · Jan 6, 2014 · 4300 views
    This topic created in 4547 days ago, the information mentioned may be changed or developed.
    www.monsieurg.fr/story/

    比如用chrome打开这个页面,使用开发者工具的时候
    下面的弹窗应该是要覆盖掉footer而不是把footer顶上来。。。
    8 replies    1970-01-01 08:00:00 +08:00
    388jintao
        1
    388jintao  
       Jan 6, 2014
    这样不是挺好的嘛,应该是你高度用的百分比的缘故吧
    kshift
        2
    kshift  
       Jan 6, 2014
    #content {
    min-height: xxxpx;
    }
    xxx 随便写个你想要的高度嘛。
    amgo
        3
    amgo  
       Jan 7, 2014
    非要这样实现的话
    footer用margin-top取一个足够大的值,别忘了删除 position: absolute及相关的

    ps:不建议你这样做,正如楼上说的,目前这样挺好的
    miniwade514
        4
    miniwade514  
       Jan 7, 2014 via Android
    不想变形就设置固定的高度值,想出现滚轮就给父元素加个 overflow-y: auto;
    Navee
        5
    Navee  
       Jan 7, 2014
    给容器一个固定的高度和宽度,再加上overflow:auto;样式应该就能达到你要的效果了
    hkongm
        6
    hkongm  
       Jan 7, 2014
    1. 元素必须有高
    2. overflow:scroll
    jazdelu
        7
    jazdelu  
    OP
       Jan 7, 2014
    回复以上
    因为想把footer一直固定在底端所以采用了position:absolute的做法。。
    但是好像窗口高度变小,中间的内容就会和footer重合在一起很不好看。。
    于是采用了

    @media only screen and (max-height : 600px) {
    #footer{
    position: relative;
    margin-top: 20px;
    }
    }
    当窗口高度小于600或其他值时将position改为relative..
    倒时可以简陋得解决这个问题。。
    housne
        8
    housne  
       Jan 7, 2014
    可以搜索下 sticky footer
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2465 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 81ms · UTC 12:15 · PVG 20:15 · LAX 05:15 · JFK 08:15
    ♥ Do have faith in what you're doing.