开发者

CSS: background-image not aligned anymore if I change zoom

If I change the zoom in my browser, the background image (the logo of my website) is positioned differently with respect to the other elements of the website.

I'm using:

background-image:url('tbs-logo.png');
background-repeat:no-repeat;
background-position: 92% 22%;

I was wondering if I can keep it aligned with the othe开发者_高级运维r elements, or I should change my html code instead to add the image with a tag.

Thanks.


I think you need to specify elements width and height with this background image. I have checked it with simple code:


<html>
<head><title>test</title>
<style type="text/css">
    #con{
        width: 500px;
        margin: 0 auto;
    }
    #img{
        width: 120px;
        height: 80px;
        background: url('ja2.jpg') 92% 22% no-repeat;
        float: left;
        border: 1px solid #000;
    }
</style>
</head>
<body>
    <div id="con">
        <div id="img"></div>
        <div>text tekst dfasdf
        saasdf dsaf dsa fas df sadf ' f
        af as dfa dsf
        ads f
         fa
         </div>
    </div>
</body>
</html>

when I zoom it, image still free in it's position

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜