2011-12-17 85 views
-1

我正在使用CSS在Html中编写网站;在我的网站我有我想要的网站,我使用CSS的顶部中间尺寸才能将低于css填充,位于网页上部中心的位置文本

background-color:#4d5152; 
position:fixed; 
width:970px; 
top: 0%; 
padding-right:200px; 
padding-left:200px; 

我的问题是这样表示的文字标识,我怎么能在上部中央位置我的标志并且使徽标的左右尺寸与徽标的颜色相同,而无需将值左右填充;所以这将是通用于所有电脑显示器的尺寸和浏览器 希望我足够清晰的 感谢您的帮助

+0

是您的徽标?把你的HTML和CSS放在这里。 – 2011-12-17 12:09:45

+0

不,它位于由CSS覆盖的HTML页面中 – user723686 2011-12-17 12:13:17

+0

您应该通过'HTML'的'TAG'来了解更多关于'HTML'的信息。并且应该用'position:fixed'来详细了解'CSS'。 – 2011-12-17 12:15:33

回答

1

通常情况下,我会写这样的事:

HTML

<html> 
<body> 
    <div id="wrapper">   
     <h1 id="logo">My Company</h1> 
    </div> 
</body> 
</html> 

CSS

#wrapper { 
    width:960px; /* Width of the containing 'wrapper' or content area */ 
    margin:0 auto; /* This will center the wrapper. 0px margin on the top and bottom, and 'auto' on the left and right (let the browser decide the amount of margin). */ 
} 

h1#logo { 
    text-align:center; /* If you don't define a width the h1 will be 100% as its parent (#wrapper). This centers the text. */ 
} 

下面是一个显示此示例的示例:http://jsfiddle.net/V5Cff/1/embedded/result/