Html CSS 定位问题:无效的属性值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40489292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:00:29  来源:igfitidea点击:

CSS positioning issues: invalid property value

htmlcsspositionpadding

提问by tagduck

SOLVED

解决了

I have some very simple HTML/CSS code, and no matter what I do, I always get an "invalid property value" exception by chrome, and the logo won't position properly. Thanks for any help.

我有一些非常简单的 HTML/CSS 代码,无论我做什么,我总是通过 chrome 收到“无效的属性值”异常,并且徽标将无法正确定位。谢谢你的帮助。

EDIT:

编辑:

Fixed the first problem, but now the image does not move related to the border. Sorry, but I'm totally new to web design and need a little bit of help.

修复了第一个问题,但现在图像不移动与边框相关。抱歉,我对网页设计完全陌生,需要一点帮助。

<html lang="de" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>my website</title>
    <style type="text/css">

        *{ padding: 0; margin: 0; }

        .header {
            width: 100%;
            height: 100px;
            border: none;
            border-bottom-style: solid;
            border-bottom-width: 5px;
            position: relative;
            border-bottom-color: rgb(220,30,60);
        }

        .logo {          
            position: absolute;
            padding-bottom:50px;
            height: 150%;
            width: auto;                
        }    

    </style>        
</head>

<body>
    <div class="header" id="header">
        <img id="logo" class="logo"  src="image.png"/>
    </div>
</body>
</html>

采纳答案by Vixed

I just don't understand why you used padding-bottominstead of bottomin this case. Anyway:

我只是不明白你为什么在这种情况下使用padding-bottom而不是底部。反正:

   <html lang="de" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <title>my website</title>
        <style type="text/css">
             *{ padding: 0; margin: 0; } 
            .header {
                position: relative;
                height: 100px;
                border-bottom: 5px solid rgb(220,30,60);
            }
            .logo {
                position: absolute;
                bottom:50px;
                height: 150%;
                width: auto;
            }
        </style>
    </head>
    <body>
     <div class="header" id="header">
        <img id="logo" class="logo"  src="image.png"/>
     </div>
    </body>
    </html>

CSS bottomproperty: http://www.w3schools.com/cssref/pr_pos_bottom.asp

CSS底部属性:http: //www.w3schools.com/cssref/pr_pos_bottom.asp

CSS padding-bottomproperty: http://www.w3schools.com/cssref/pr_padding-bottom.asp

CSS padding-bottom属性:http: //www.w3schools.com/cssref/pr_padding-bottom.asp

回答by Manohar Reddy Poreddy

I had a similar issue for me.

我有一个类似的问题。

I wrote 10, instead of 10px

我写了10,而不是10px

Hope that helps.

希望有帮助。

回答by Paul Redmond

There's a space before the pxin padding-bottom:50 px;. Fix:

pxin之前有一个空格padding-bottom:50 px;。使固定:

padding-bottom: 50px;