div and classes SOLVED
Moderator: General Moderators
div and classes SOLVED
i need a centered division. i noticed that align is dprecated. by making a class and using text-align:center i found that the line with the text align is ignored (using mozilla 1.3.1 haven't checked othere)
anyone know why? until i can find a way to make it work with the class i'm using align. i would like to move to the class.
anyone know why? until i can find a way to make it work with the class i'm using align. i would like to move to the class.
Last edited by m3rajk on Thu Oct 02, 2003 1:27 pm, edited 1 time in total.
Code: Select all
pageCoords = new getPageCoords();
function centerAlign(id) {
divObj = document.getElementById(id)
if(pageCoords.width > 760) {
newLeft = Math.ceil(((pageCoords.width - parseInt(divObj.offsetWidth())) /2));
} else newLeft = 0;
divObj.style.left = newLeft;
}
function getPageCoords() {
this.width = (is.ns || is.ns6up) ? window.outerWidth:document.body.clientWidth;
this.height = (is.ns || is.ns6up) ? window.innerHeight:document.body.offsetHeight;
return this;
}This script will allow you to center any div inside a browserwindow. as of now the above script is not really crossbrowser but if you want to have a look at my original script just say so.
Regards,
//cybaf
- Vincent Puglia
- Forum Commoner
- Posts: 67
- Joined: Thu Sep 04, 2003 4:20 pm
- Location: where the World once stood
the class i had turned the font-face and font-color correctly. it didn't work so i made a test one ...Vincent Puglia wrote:Hi
Did you try:
VinnyCode: Select all
<center><div id="Test" style="...."> </div></center>
Code: Select all
.center{ text-align:center }Code: Select all
<html><head><title>div class test</title><style type="text/css">@import url(textStyle.css);</style></head><body>
<div class="center">testing centering</div>
</body></html>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Try changing your CSS from:
to
as Unipus suggested.
Mac
Code: Select all
.center{ text-align:center }Code: Select all
.center {
text-align: center;
margin-left: auto;
margin-right: auto;
}Mac