CSS:为什么chrome中的字母在像素缩放中被不同颜色包围?

时间:2016-03-31 12:42:00

标签: html css twitter-bootstrap css3 twitter-bootstrap-3

我有一个带有h1标头的bootstrap jumbotron。当我将h1标题更改为h2时,我发现包围颜色的字母发生了变化:

带有h1标题的图片:

enter image description here

带有h2标题的图片:

enter image description here

image1 html代码:

<div class="container">
  <div class="jumbotron">
     <h1>Admin Template</h1>
     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do</p>
  </div>
</div>

image1 css代码:

@media screen and (min-width: 768px)
.jumbotron h1, .jumbotron .h1 {
    font-size: 63px;
}
.jumbotron h1, .jumbotron .h1 {
    color: inherit;
}
h1, .h1 {
    font-size: 36px;
}
h1, .h1, h2, .h2, h3, .h3 {
    margin-top: 20px;
    margin-bottom: 10px;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: inherit;
    font-weight: 300;
    line-height: 1.1;
    color: #fff;
}
h1 {
    font-size: 2em;
    margin: 0.67em 0;
}
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
user agent stylesheet
h1 {
    display: block;
    font-size: 2em;
    -webkit-margin-before: 0.67em;
    -webkit-margin-after: 0.67em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
    font-weight: bold;
}
Inherited from div.jumbotron
.jumbotron {
    padding-top: 30px;
    padding-bottom: 30px;
    margin-bottom: 30px;
    color: inherit;
    background-color: #252830;
}
Inherited from body
body {
    font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.42857143;
    color: #CFD2DA;
    background-color: #252830;
    font-weight: 300;
}
Inherited from html
html {
    font-size: 10px;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
html {
    font-family: sans-serif;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}
Pseudo ::before element
*:before, *:after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
Pseudo ::after element
*:before, *:after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

image2 html代码:

<div class="container">
  <div class="jumbotron">
     <h2>Admin Template</h2>
     <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do</p>
  </div>
</div>

image2 css代码:

h2, .h2 {
    font-size: 30px;
}
h1, .h1, h2, .h2, h3, .h3 {
    margin-top: 20px;
    margin-bottom: 10px;
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: inherit;
    font-weight: 300;
    line-height: 1.1;
    color: #fff;
}
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
user agent stylesheet
h2 {
    display: block;
    font-size: 1.5em;
    -webkit-margin-before: 0.83em;
    -webkit-margin-after: 0.83em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
    font-weight: bold;
}
Inherited from div.jumbotron
.jumbotron {
    padding-top: 30px;
    padding-bottom: 30px;
    margin-bottom: 30px;
    color: inherit;
    background-color: #252830;
}
Inherited from body
body {
    font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.42857143;
    color: #CFD2DA;
    background-color: #252830;
    font-weight: 300;
}
Inherited from html
html {
    font-size: 10px;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
html {
    font-family: sans-serif;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}
Pseudo ::before element
*:before, *:after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
Pseudo ::after element
*:before, *:after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

这种行为有什么解释吗? 是否可以始终用灰色环绕文本?

1 个答案:

答案 0 :(得分:0)

尝试将此添加到文字属性中。

 -webkit-font-smoothing: antialiased;

感谢。