Question:
change css with javascript?
Tasm
2010-09-15 13:05:43 UTC
Please I need to align the tag that is added to the picture when you click it so that it is valigned middle, but it doesn't work. I have to do this using javascript, can anyone help? Here is the html and css file. The image is just a colored rectangle.














__________________________
css tc2.css

#logo{
cursor:hand;
background-attachment: fixed;
width:74px;
height:61px;
background-image:url('test.PNG');
float: left;
font-size: 12px;
}
Three answers:
2010-09-16 01:10:39 UTC
Floating elements removes that element from the document flow. I would also redo the background CSS:



background: url('test.PNG') no-repeat center fixed;



Always tell the browsers what you want them to do. Otherwise, you get default placements and parsing of your code.



Ron
buras
2016-10-06 06:40:13 UTC
attempt this : HTML : JAVASCRIPT: var flag = 0; functionality toggle(){ if (flag==0) { checklist.getElementById('css').href = 'alt.css'; flag=a million; } else { checklist.getElementById('css').href = 'def.css'; flag=0; } }
Stas S
2010-09-15 13:23:04 UTC
Try to change div_.style.verticalAlign="middle";

with div_.style.marginTop = "45%";



then play with percents


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...