chrome 不尊重字体系列 ('PT Sans')
chrome does not respect font-family ('PT Sans')
我有一个用 HTML
编写的网页,其中我有一个 button
。除了我的按钮,所有页面都尊重 font-family: 'PT Sans', sans-serif
。
body {
font-family: 'PT Sans', sans-serif;
margin: 0px 0px 0px 0px;
}
这是 table:
中的按钮元素
<button id="createCampaignButton" class="yellowButton" nowrap>CREATE NEW CAMPAIGN</button>
我也使用了如下的 <style>
标签,它会改变字体颜色而不是字体系列。
button {
font-family: 'PT Sans', sans-serif;
color: red
}
我在这里搜索过,但其中 none 个对我有用。
我的风格-sheet:
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
.yellowButton {
border: 0 solid #FFCC00;
width:100%;
/*height: 50px;*/
font-size: 16px;
font-weight: bold;
background-color: #FFCC00;
padding: 12px 20px;
box-shadow: 0 2px 2px 0 #C2C2C2;
border-radius: 2px;
outline:none;
}
.yellowButton:active {
border: 0 solid #FFCC00;
width:100%;
/*height: 50px;*/
font-size: 16px;
font-weight: bold;
background-color: #FFCC00;
padding: 12px 20px;
box-shadow: 0 0 0 0 #C2C2C2;
border-radius: 2px;
outline: none;
}
更新
现在我注意到问题只出在 'PT Sans'
字体上!所有其他字体都可以正常工作。
你有没有包含这个文件??
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
如果不是刚刚过去 header。
或者如果你想在 css 中使用这个
@import url(https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700,700italic);
您可以在 chrome 中使用右键单击和 "inspect" 来查看哪些样式正在使用并覆盖其他样式。
如果您检查该元素,您会看到哪些内容覆盖了哪些内容,哪些内容拼写错误,旁边有一个黄色的小警告图标。
问题已经解决,将这一行添加到样式中,据我了解,table
中的 button
不会从 body
样式继承样式。主要问题是我应该清理浏览器的缓存。
button{
font-family: 'PT Sans', sans-serif;
}
我有一个用 HTML
编写的网页,其中我有一个 button
。除了我的按钮,所有页面都尊重 font-family: 'PT Sans', sans-serif
。
body {
font-family: 'PT Sans', sans-serif;
margin: 0px 0px 0px 0px;
}
这是 table:
中的按钮元素<button id="createCampaignButton" class="yellowButton" nowrap>CREATE NEW CAMPAIGN</button>
我也使用了如下的 <style>
标签,它会改变字体颜色而不是字体系列。
button {
font-family: 'PT Sans', sans-serif;
color: red
}
我在这里搜索过,但其中 none 个对我有用。
我的风格-sheet:
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
.yellowButton {
border: 0 solid #FFCC00;
width:100%;
/*height: 50px;*/
font-size: 16px;
font-weight: bold;
background-color: #FFCC00;
padding: 12px 20px;
box-shadow: 0 2px 2px 0 #C2C2C2;
border-radius: 2px;
outline:none;
}
.yellowButton:active {
border: 0 solid #FFCC00;
width:100%;
/*height: 50px;*/
font-size: 16px;
font-weight: bold;
background-color: #FFCC00;
padding: 12px 20px;
box-shadow: 0 0 0 0 #C2C2C2;
border-radius: 2px;
outline: none;
}
更新
现在我注意到问题只出在 'PT Sans'
字体上!所有其他字体都可以正常工作。
你有没有包含这个文件??
<link href='https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
如果不是刚刚过去 header。
或者如果你想在 css 中使用这个
@import url(https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700,700italic);
您可以在 chrome 中使用右键单击和 "inspect" 来查看哪些样式正在使用并覆盖其他样式。
如果您检查该元素,您会看到哪些内容覆盖了哪些内容,哪些内容拼写错误,旁边有一个黄色的小警告图标。
问题已经解决,将这一行添加到样式中,据我了解,table
中的 button
不会从 body
样式继承样式。主要问题是我应该清理浏览器的缓存。
button{
font-family: 'PT Sans', sans-serif;
}