html - 即使我复制并粘贴了代码,我的字体和文本大小类也不起作用
问题描述
在我的网站上,我有一个更改字体和文本大小的类,名为class='q'
. 即使我从主页复制并粘贴此课程,该课程也无法工作,因为它是所有页面的菜单栏。所有其他类都有效,但这一类无效,为什么?
th.q {
font-family: avenir;
font-size: 25px;
}
<BODY>
<TABLE class='a' border='0' width='100%'>
<TR height='20%'>
<TH class='q'><a class="hover">About</a></TH>
<TH class='q'><a>Products</a></TH>
<TH class='q'><a>Pricing</a></TH>
<TH class='q'><a>Contact</a></TH>
</TR>
</TABLE>
解决方案
(参考你的回答:)
不幸的是,为多个元素提供相同的内容id
会使您的 HTML 无效。如果#font
选择器足以解决问题,您应该能够改为提供<table>
anid
并选择其<th>
后代:
#navigation th {
font-size: 25px;
}
<TABLE id='navigation' class='a' border='0' width='100%'>
<TR height='20%'>
<TH><a class="hover">About</a></TH>
<TH><a>Products</a></TH>
<TH><a>Pricing</a></TH>
<TH><a>Contact</a></TH>
</TR>
</TABLE>
此外,border
、width
和height
属性应该在 CSS 中,而不是 HTML:
#navigation th {
font-size: 25px;
}
#navigation {
border: none;
width: 100%;
}
#navigation tr {
height: 20%;
}
<TABLE id='navigation' class='a'>
<TR>
<TH><a class="hover">About</a></TH>
<TH><a>Products</a></TH>
<TH><a>Pricing</a></TH>
<TH><a>Contact</a></TH>
</TR>
</TABLE>
当然,无论如何,您不应该使用表格进行布局。
推荐阅读
- css - 使用 CSS 动画关闭 SVG 框的盖子
- javascript - ThreeJS 和 Typescript:如何跟踪或勾勒对象旋转的路径?
- mongodb - 在本地托管 mongoDB 数据库,并能够从外部网络连接
- python - 尝试计算 dask 数据帧时出错
- python - Python - 是否有为提取的 .DOC 文件创建标题?
- android - Android Studio - 文件系统同步
- python - 将pyspark中的数据帧编码为0和1
- java - Java - ExecutorService 在一段时间后停止处理线程
- bpf - 使用 uBPF 打印 Hello World?
- typescript - 基于请求/响应的 rxjs WebSocketSubject 的不同类型(下一个 msg 类型,订阅 msg 类型),但只允许一个泛型