V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
likai
V2EX  ›  问与答

最简单的 css 背景问题请教

  •  
  •   likai · 2015-03-30 22:18:18 +08:00 · 1838 次点击
    这是一个创建于 3351 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <!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 条回复    2015-03-31 22:32:47 +08:00
    abelyao
        1
    abelyao  
       2015-03-30 23:17:28 +08:00
    想表达什么问题?
    wxt2005
        2
    wxt2005  
       2015-03-31 06:29:40 +08:00 via iPhone   ❤️ 1
    把background-image改成background
    likai
        3
    likai  
    OP
       2015-03-31 22:02:02 +08:00
    @wxt2005 还真是。这是为啥?
    @abelyao 苦逼解决不了跑这求助啊
    wxt2005
        4
    wxt2005  
       2015-03-31 22:32:47 +08:00   ❤️ 1
    @likai 你的这句 url(lg.jpg) no-repeat left center 其实描述了三个属性:background-image, background-repeat, background-position。
    然而你的属性名却是background-image,那显然是非法的。改成background之后就成为简写属性了,就可以同时容纳这几个属性值。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1400 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:36 · PVG 01:36 · LAX 10:36 · JFK 13:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.