[英]Converting Inline style sheet to an external style sheet
我在文件中关注了SyleSheet。
CSS
<table style="font-family:Comic Sans MS;margin-left:auto;margin-right:auto;">
<tr>
<td colspan="2" style="width:1000px;height:30px;background-color:Gray;">
</td>
</tr>
<tr>
<td style="width:200px;height:600px;background-color:Lime;">
</td>
<td style="width:800px;height:600px;background-color:Maroon;">
</td>
</tr>
<tr>
<td colspan="2" style="width:1000px;height:30px;background-color:Olive;">
</td>
</tr>
</table>
我想要的是在上面的表格中制作一个独立的样式表,以便可以在其他表上应用该样式表。总而言之,我想将内联样式表转换为外部样式表。
我试过了,但是由于有相同的td需要用不同的样式来使我感到困惑。我知道我可以使用class属性,但是如果还有其他可能的话请告诉我。
下面应该这样做:
table{
font-family:Comic Sans MS;margin-left:auto;margin-right:auto;
}
tr:nth-child(1) td{
width:1000px;height:30px;background-color:Gray;
}
tr:nth-child(2) td:first-child{
width:200px;height:600px;background-color:Lime;
}
tr:nth-child(2) td:last-child{
width:800px;height:600px;background-color:Maroon;
}
tr:nth-child(3) td{
width:1000px;height:30px;background-color:Olive;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.