sennes
V2EX  ›  问与答

网站按钮位置适应

  •  
  •   sennes · Apr 12, 2015 · 1833 views
    This topic created in 4049 days ago, the information mentioned may be changed or developed.

    帮别人修改网站,对方是完全不懂的。
    我也就懂一点点。
    想请教一下怎么把play.png正好和index.png的相应位置重合?
    我试过设定绝对的位置,不过换个浏览器或者换个手机就错位了

    http://i.v2ex.co/QpSYhT5Jl.png

    给出一部分代码,有需要的话再贴。

    .start{
            background: url("img/index.png") no-repeat center;
            height: 535px;
        }
        #play{
            position: absolute;
            bottom: 40%;
            left: 34%;
        }
    </style>
    <script type="text/javascript" src="js/game.js"></script>
    

    </head>
    <body>
    <div class="start">
    <img id="play" src="img/play.png">
    </div>

    我觉得是改CSS #play 的这个位置就可以了。不过改来改去都不满意。
    大家有什么建议? 先谢谢大家。

    2 replies    2015-04-12 17:35:21 +08:00
    icyflash
        1
    icyflash  
       Apr 12, 2015
    div.start要设置width min-width position为relative
    #play不要用定位不要用百分比,用px

    不过你这个。。根本就不应该这么去弄
    play.png那个根本没必要
    要在index.png那上面的play加上按钮的话
    直接用一个a display:block 设置相应的长宽 其它的就根上面说的一样,调位置。
    sennes
        2
    sennes  
    OP
       Apr 12, 2015
    @icyflash 谢谢,我去试试
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1140 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 18:12 · PVG 02:12 · LAX 11:12 · JFK 14:12
    ♥ Do have faith in what you're doing.