![](/img/trans.png)
[英]Difference in applying CSS to html, body, and the universal selector *?
[英]Title and Universal Selector (*) in Javascript CSS/HTML5
如何在以下div中添加標題?
document.write('<div style="width:auto; margin:10px;"><table style="background-color:purple;"
border="1" cellspacing="1" cellpadding="35">')
以下是完整的腳本:
<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>
如何使用通用選擇器(*)使所有字體大小相同?
只需在表內添加一個<caption>
元素:
document.write('<div style="width:auto; margin:10px;"><table style="background-
color:purple;" border="1" cellspacing="1" cellpadding="35"><caption>Title</caption>')
對於*通用選擇器,我相信您要使用CSS:
<style type="text/css">
*{
font-size: 12px;
}
</style>
嘗試這個:
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.