2013-04-14 73 views
0

嗨,好吧,我基本上想要我的徽标div在我的topBar div中,但是当我使用填充或边距时,它会将整个顶部条向下移动,或者徽标只是重复其自身(并且是的,我尝试了背景重复:无重复)在div内移动div?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
<link href="style/style.css" rel="stylesheet" type="text/css" /> 
</head> 

<body lang="en"> 
<div class="alert">Do you want advertsing space? Contact us: <b>[email protected]</b></div> 
<div class="topBar"> 
<div id="logo"> 
<p>chattrd</p> 
</div> 
</div> 
</body> 
</html> 

body { 
    background: #F7F7F7; 
    font-family:Tahoma, Geneva, sans-serif; 
    margin: 0; 
    padding: 0; 
} 
.alert { 
    font-size: 10px; 
    color: #FFF; 
    background: #1f1f1f; 
    height: 14px; 
    padding-left: 10px; 
    font-family: Arial; 
} 
.topBar { 
    background: #0C3; 
    height: 40px; 
} 
#logo { 
    background-image:url(../images/logo.png); 
    height: 26px; 
    width: 121px; 
    overflow: hidden; 
    display: block; 
    text-indent:-999px; 
} 
+0

显示您拥有的标记和CSS。 – JJJ

+1

发布您的代码和标记。这是一个质量保证网站,不是一个猜测网站。 – Ejaz

+0

有你去了,Ejay我只是觉得你以前可能会遇到过这样的问题。 – user2279169

回答

0

它表现这种方式的原因是您正在使用图像作为背景。如果你想用这种方法来进行,以便能够上下移动它的最简单的方法是前,像这样#徽标div来放置另一个DIV:

<body lang="en"> 
<div class="alert">Do you want advertsing space? Contact us: <b>[email protected]</b></div> 
<div class="topBar"> 
<div id="spaceDiv"></div> 
<div id="logo"></div> 
</div> 
</body> 

的spaceDiv的高度可以用来使用以下CSS移动#logo-div:

#spaceDiv{ 
    height:6px; 
}