使用CSS时Chrome上的模糊文本
我在用着
-webkit-transform: skew(-15deg, 0deg);
歪斜div,然后
-webkit-transform: skew(15deg, 0deg);
歪斜含有文字的孩子。 歪斜看起来丑陋和像素化在谷歌浏览器,所以我使用
-webkit-backface-visibility: hidden;
使其看起来不错。 现在容器倾斜得非常好,内部文字“不纠结”,但文字本身模糊又丑陋! (问题只存在于使用-webkit的chrome中)
演示
任何想法如何使文本再次清晰?
HTML
<div class="mainBodyItemBox">
<div class="mainBodyItemImage">
<img src="http://upload.wikimedia.org/wikipedia/commons/6/6c/2012_Olympic_Football_-_Men's_tournament_-_Honduras_Vs_Morocco.jpg">
</div>
<div class="mainBodyItemDecorator"></div>
<div class="mainBodyItemText">PEC Zwolle v FC Groningen Tickets
<br> <span class="mainBodyItemType">Football</span>
<span class="mainBodyItemTime"><strong>04 Apr 2014</strong> | 21:00</span>
</div>
</div>
CSS
.mainBodyItemBox {
background-color: #f5f5f5;
display: inline-block;
font-family: Arial;
font-size: 12px;
height: 80px;
width: 365px;
border-top: 1px solid #ffffff;
border-bottom: 1px solid #c9c9c9;
margin-left: 25px;
margin-top: 10px;
transform: skew(-10deg, 0deg);
-webkit-transform: skew(-10deg, 0deg);
-moz-transform: skew(-10deg, 0deg);
-o-transform: skew(-10deg, 0deg);
-ms-transform: skew(-10deg, 0deg);
overflow: hidden;
-webkit-backface-visibility: hidden;
}
.mainBodyItemImage {
height: 100%;
width: 125px;
float: left;
overflow: hidden;
}
.mainBodyItemDecorator {
float: right;
height: 100%;
width: 10px;
background: rgb(30, 143, 30);
background: url(data:image/svg+xml;
base64, PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJod…EiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(30, 143, 30, 1)), color-stop(100%, rgba(71, 209, 21, 1)));
background: -webkit-linear-gradient(top, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
background: -o-linear-gradient(top, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
background: -ms-linear-gradient(top, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
background: linear-gradient(to bottom, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1e8f1e', endColorstr='#47d115', GradientType=0);
}
.mainBodyItemText {
color: #323d50;
font-size: 15px;
height: 100%;
margin-left: 125px;
padding-left: 15px;
padding-top: 5px;
transform: skew(10deg, 0deg);
-webkit-transform: skew(10deg, 0deg);
-moz-transform: skew(10deg, 0deg);
-o-transform: skew(10deg, 0deg);
-ms-transform: skew(10deg, 0deg);
}
.mainBodyItemType {
color: #9aa7af;
font-size: 10px;
margin-top: 0px;
}
.mainBodyItemTime {
font-size: 12px;
margin-top: 0px;
position: absolute;
bottom: 10px;
left: 15px;
}
我不确定这将是解决模糊文本的可行解决方案,但我创建了一些似乎可以避免该问题的方法。
我使用的技巧是封装所有需要transform: skew(-10deg, 0deg)
元素transform: skew(-10deg, 0deg)
在容器中transform: skew(-10deg, 0deg)
并将容器绝对transform: skew(-10deg, 0deg)
在文本后面。 这样,文本不受任何转换,因此不需要进行纠偏。 我尝试以不同的方式分离文本,但仅仅靠近转换的元素仍然导致模糊的文本。
我创建了2个演示, 这一个保留原始的HTML, 这一次使用的东西有点更清洁,更语义。 后面我也列出了下面的代码。
HTML
<article>
<section>
<h1>PEC Zwolle v FC Groningen Tickets</h1>
<p>Football</p>
<time><strong>04 Apr 2014</strong> | 21:00</time>
</section>
<aside>
<img src="http://upload.wikimedia.org/wikipedia/commons/6/6c/2012_Olympic_Football_-_Men's_tournament_-_Honduras_Vs_Morocco.jpg" /><b></b>
</aside>
</article>
CSS
article, aside {
font-size: 12px;
height: 80px;
width: 365px;
}
article {
display: inline-block;
font-family: Arial;
position:relative;
margin-left: 25px;
margin-top: 10px;
}
aside {
position:absolute;
z-index:-1;
top:0;
left:0;
background-color: #f5f5f5;
border-top: 1px solid #ffffff;
border-bottom: 1px solid #c9c9c9;
transform: skew(-10deg, 0deg);
-webkit-transform: skew(-10deg, 0deg);
-moz-transform: skew(-10deg, 0deg);
-o-transform: skew(-10deg, 0deg);
-ms-transform: skew(-10deg, 0deg);
-webkit-backface-visibility: hidden;
}
img {
height: 100%;
width: 125px;
}
aside b {
right:0;
top:0;
position:absolute;
height: 100%;
width: 10px;
background: rgb(30, 143, 30);
background: url(data:image/svg+xml;
base64, PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJod…EiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(30, 143, 30, 1)), color-stop(100%, rgba(71, 209, 21, 1)));
background: -webkit-linear-gradient(top, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
background: -o-linear-gradient(top, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
background: -ms-linear-gradient(top, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
background: linear-gradient(to bottom, rgba(30, 143, 30, 1) 0%, rgba(71, 209, 21, 1) 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#1e8f1e', endColorstr='#47d115', GradientType=0);
}
section {
color: #323d50;
height: 100%;
margin-left:140px;
}
section h1 {
font-size:15px;
font-weight:normal;
margin:5px 0 0;
}
section p {
color: #9aa7af;
font-size: 10px;
margin: 5px 0;
}
time {
font-size: 12px;
}
这是基于你的简单版本:
具有自动宽度! :)
https://jsfiddle.net/CastelMTL/x2Lhhdmj/1/
HTML:
<article>
<section>
<p>Football</p>
</section>
<aside>
</aside>
</article>
<article>
<section>
<p>Football Player</p>
</section>
<aside>
</aside>
</article>
CSS:@import url(http://fonts.googleapis.com/css?family=Lato:400,700,900,900italic);
article, aside {
font-size: 12px;
height: 30px;
width:auto;
}
article {
display: inline-block;
font-family: Arial;
position:relative;
margin-left: 25px;
margin-top: 10px;
}
aside {
width:100%;
position: absolute;
z-index: -1;
top: 0;
left: 0;
border-width: 4px;
border-color: red;
background-color: #f5f5f5;
border: 3px solid #04B552;
border-radius: 3px;
/* border-bottom: 1px solid #c9c9c9; */
transform: skew(-10deg, 0deg);
-webkit-transform: skew(-10deg, 0deg);
-moz-transform: skew(-10deg, 0deg);
-o-transform: skew(-10deg, 0deg);
-ms-transform: skew(-10deg, 0deg);
-webkit-backface-visibility: hidden;
}
section {
color: #323d50;
height: 30px;
margin-left:0px;
display: block;
}
section p {
font-family:'lato';
font-size:15px;
line-height:15px;
font-weight:normal;
margin:10px 15px;
}
time {
font-size: 12px;
}
链接地址: http://www.djcxy.com/p/78405.html
上一篇: Blurry text on Chrome when using CSS
下一篇: Multiprocessing : NULL result without error in PyObject