likai
V2EX  ›  问与答

最简单的 css 背景问题请教

  •  
  •   likai · Mar 30, 2015 · 2341 views
    This topic created in 4107 days ago, the information mentioned may be changed or developed.
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta charset="UTF-8">
    <style>
    body{
    margin:0;
    padding:0;

    }
    #logo img{
    margin:0 auto ;
    max-width: 100%;
    height: auto;
    width: auto;
    }
    #logo{margin:0 auto ;
    padding: 0;}
    #main{
    margin:0;
    background-attachment: scroll;
    background-image:url(lg.jpg) no-repeat left center;
    -moz-background-size:100% 100%;
    background-size:100% 100%;
    height: 1000px;


    }
    </style>
    </head>
    <body>
    <div >

    <div id="logo"><img src="./logo.jpg" /></div>


    <div id="main">111</div>

    </div>
    </body>
    </html>


    背景和文件在同一文件夹,
    4 replies    2015-03-31 22:32:47 +08:00
    abelyao
        1
    abelyao  
       Mar 30, 2015
    想表达什么问题?
    wxt2005
        2
    wxt2005  
       Mar 31, 2015 via iPhone   ❤️ 1
    把background-image改成background
    likai
        3
    likai  
    OP
       Mar 31, 2015
    @wxt2005 还真是。这是为啥?
    @abelyao 苦逼解决不了跑这求助啊
    wxt2005
        4
    wxt2005  
       Mar 31, 2015   ❤️ 1
    @likai 你的这句 url(lg.jpg) no-repeat left center 其实描述了三个属性:background-image, background-repeat, background-position。
    然而你的属性名却是background-image,那显然是非法的。改成background之后就成为简写属性了,就可以同时容纳这几个属性值。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   936 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 19:11 · PVG 03:11 · LAX 12:11 · JFK 15:11
    ♥ Do have faith in what you're doing.