[英]HTML table cell width
所以我有這個代碼顯示HTML表格中的XML文件的信息。 我想讓一個單元格大於另一個單元格。 我試過用
<td width="70%">
但這並沒有解決我的問題。
我的部分代碼:
<table bgcolor="#00FF00"></table>
<style type="text/css">
table,th,td {border : 5px solid #F7B896; border-collapse: collapse;}
th,td { padding-top: 10px; background-color:white;}
table {style=width:100%;}
</style>
for (i = 0; i < songTitles.length; i++) {
table += "<tr><td>" +
songTime[i].attributes.getNamedItem("StartTime").nodeValue +
"</td><td><b>" +
artistNames[i].attributes.getNamedItem("name").nodeValue +
"</b> - " +
songTitles[i].attributes.getNamedItem("title").nodeValue +
"</td></tr>"
這是我的完整代碼: https : //newfmplayer.online/loadxml以下是我的表格看起來如何https://newfmplayer.online/lastaired.html 。 我想讓藝術家和歌曲名稱更大,時間單元格更小。
編輯 :
所以讓我們更准確一點,最好的方法是在td中添加一個類,你想要比標記中添加那個類更大,你在css中也有一個錯字
<style type="text/css">
table,th,td {border : 5px solid #F7B896; border-collapse: collapse;}
th,td { padding-top: 10px; background-color:white;}
td.bigger{width:70%}
table {width:100%;}
</style>
<table bgcolor="#00FF00"></table>
<script>
for (i = 0; i < songTitles.length; i++) {
table += "<tr><td>" + //assuming you want the second bigger
songTime[i].attributes.getNamedItem("StartTime").nodeValue +"</td><td class='bigger'><b>" +
artistNames[i].attributes.getNamedItem("name").nodeValue + "</b> - " +
songTitles[i].attributes.getNamedItem("title").nodeValue + "</td></tr>"
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.