我在使用。
扭曲一个div,然后...
-webkit-transform: skew(-15deg, 0deg);
扭曲一个div,然后...
-webkit-transform: skew(15deg, 0deg);
将包含文本的子元素进行去斜。在Google Chrome中,倾斜看起来很丑陋和像素化,所以我使用了
-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;
}
backface-visibility
,因为没有明显的模糊。您还可以将-webkit-backface-visibility: hidden
添加到文本中以消除像素化。 - andyb