[英]Title and Universal Selector (*) in Javascript CSS/HTML5
How do I add a title to the following div? 如何在以下div中添加标题?
document.write('<div style="width:auto; margin:10px;"><table style="background-color:purple;"
border="1" cellspacing="1" cellpadding="35">')
Below is the complete script: 以下是完整的脚本:
<html>
<body>
<script Language="JavaScript">
rows = 6;
cols = 6;
document.write('<div style="width:auto; margin:10px;"><table style="background-color:purple;"
border="1" cellspacing="1" cellpadding="35">')
/* Not apart of the Table */
//document.write('<h3> <center>Table </center> </h3>')
for (i = 0; i < rows; i++) {
document.write('<tr>')
for (j = 0; j < cols; j++)
{
document.write('<td style="color:orange;">' + (i*j) + '</td>')
}
document.write('</tr>')
}
document.write('</table></div>')
</script>
</body>
</html>
How do I also use a Universal Selector (*) to make all the font size the same? 如何使用通用选择器(*)使所有字体大小相同?
Just add a <caption>
element inside the table: 只需在表内添加一个
<caption>
元素:
document.write('<div style="width:auto; margin:10px;"><table style="background-
color:purple;" border="1" cellspacing="1" cellpadding="35"><caption>Title</caption>')
for the * universal selector I believe you want css: 对于*通用选择器,我相信您要使用CSS:
<style type="text/css">
*{
font-size: 12px;
}
</style>
Try this: 尝试这个:
var elements = document.getElementsByTagName("*");
for (var i = 0, len = elements.length; i < len; i++) {
var element = elements[i];
element.style.fontSize = "20px"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.