I don't see this question answered anywhere else here.
Here's the code:
<div class="copyright">
<h2 class="copyright unselectable" onselectstart="return false">
© 2009 - <?=date("Y") ?> <?开发者_StackOverflow=PROJECT_NAME?>
</h2>
</div>
It's aligning right in IE but not FF or Safari. It seems to not be taking into account the spacing for the echoed text?
Thanks!
Edit: Adding css that is there:
div.copyright h2.copyright{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:13px;
color:#000000;
font-weight:bold;
text-align:center;
}
Second Edit: Well I just hard coded the text with the same results...so it's not the echo issue like I though. I'll have to look deeper at this.
Just add a style
attribute to H2
:
<h2 class="copyright unselectable" onselectstart="return false" style="text-align:center">
© 2009 - <?=date("Y") ?> <?=PROJECT_NAME?>
</h2>
Or better, add that property to your CSS rule for .copyright
:
.copyright {
text-align: center;
/* … */
}
The code sample that you posted seems to be aligning correctly to the center in both Firefox and Safari (on a Mac). The correct CSS to use is text-align: center;
. What is the HTML and the associated CSS surrounding that piece of code? There could be something else causing the text to not look centered.
OK. I fixed it-and the answer is too stupid to post here...
...haha The box above the copyright area was not centering right in ff and safari but was right in IE. :-D
You can try
div.copyright h2.copyright{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:13px;
color:#000000;
margin:0 auto;
font-weight:bold;
text-align:center;
}
Try giving the h2 a width. If you're using a reset stylesheet it's default styling may have been over ridden. If the h2 isn't wider than it's text, then it will appear that the text isn't being centered.
精彩评论