我知道这应该很容易,但我不知道自己做错了什么。我只想用一个Font Awesome图标替换png背景图像(css)。
这是整个css文件:
.wc-bookings-date-picker .ui-datepicker{padding:0;width:auto;}
.wc-bookings-date-picker .ui-widget-content{border:0;background:#fff;-moz-box-shadow:0 1px 3px rgba(0,0,0,.19);-webkit-box-shadow:0 1px 3px rgba(0,0,0,.19);box-shadow:0 1px 3px rgba(0,0,0,.19);}
.wc-bookings-date-picker .ui-datepicker-header{padding:0;overflow:hidden;text-transform:uppercase;border-radius:4px 4px 0 0;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;background-color:#999;background-image:none;background-image:-moz-linear-gradient(bottom,#999 0,#aaa 100%);background-image:-o-linear-gradient(bottom,#999 0,#aaa 100%);background-image:-webkit-linear-gradient(bottom,#999 0,#aaa 100%);background-image:linear-gradient(bottom,#999 0,#aaa 100%);border:0;border-top:1px solid #999;color:#fff;}
.wc-bookings-date-picker .ui-datepicker-header .ui-state-hover{background:0 0;border-color:transparent;cursor:pointer;}
.wc-bookings-date-picker .ui-datepicker .ui-datepicker-title{line-height:1em;font-weight:400;padding:.75em 0;}
.wc-bookings-date-picker .ui-datepicker .ui-datepicker-next,.wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev{top:-1px;background:#999;border-radius:0;font-weight:400;height:2.5em;width:2em;}
.wc-bookings-date-picker .ui-datepicker .ui-datepicker-next.ui-state-hover,.wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev.ui-state-hover{background:#aaa;}
.wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev{left:0;border:0;}
.wc-bookings-date-picker .ui-datepicker .ui-datepicker-next{right:0;border:0;}
.wc-bookings-date-picker .ui-datepicker .ui-datepicker-next span,.wc-bookings-date-picker .ui-datepicker .ui-datepicker-prev span{margin-top:-4px;top:40%;}
.wc-bookings-date-picker .ui-icon-circle-triangle-e{background-image:url(../images/ui-icons_ffffff_256x240.png);background-position:-32px 0;}
.wc-bookings-date-picker .ui-icon-circle-triangle-w{background-image:url(../images/ui-icons_ffffff_256x240.png);background-position:-96px 0;}
.wc-bookings-date-picker .ui-datepicker table{margin:0;}
.wc-bookings-date-picker .ui-datepicker th{padding:.75em 0;text-transform:uppercase;color:#bbb;font-weight:400;border-top:1px solid #e6e6e6;background:#fefefe;}
.wc-bookings-date-picker .ui-datepicker td{border:0;border-top:1px solid #e6e6e6;border-right:1px solid #e6e6e6;background:#fefefe;padding:0!important;}
.wc-bookings-date-picker .ui-datepicker td:last-child{border-right:0;}
.wc-bookings-date-picker .ui-datepicker td .ui-state-default{background:0 0;background-image:none!important;border:0;color:#2b2b2b;margin:0;font-weight:400;text-align:center;padding:.75em 0;}
.wc-bookings-date-picker .ui-datepicker td a.ui-state-active,.wc-bookings-date-picker .ui-datepicker td a.ui-state-active.ui-state-hover{background:#fefefe;color:#b2b2b2;background-image:none!important;}
.wc-bookings-date-picker .ui-datepicker td.fully_booked a,.wc-bookings-date-picker .ui-datepicker td.fully_booked span{background-color:#c0392b!important;background-image:none!important;border-color:rgba(0,0,0,.1)!important;color:#fff!important;text-shadow:0 1px 0 rgba(0,0,0,.1);}
.wc-bookings-date-picker .ui-datepicker td.bookable a{background-color:#2ecc71!important;background-image:none!important;border-color:rgba(0,0,0,.1)!important;color:#fff!important;text-shadow:0 1px 0 rgba(0,0,0,.1);}
.wc-bookings-date-picker .ui-datepicker td.partial_booked a{background-color:#2ecc71!important;background-image:none!important;border-color:rgba(0,0,0,.1)!important;color:#fff!important;text-shadow:0 1px 0 rgba(0,0,0,.1);position:relative;z-index:1;}
.wc-bookings-date-picker .ui-datepicker td.partial_booked a:before{content:"";position:absolute;top:0;left:0;width:0;height:0;border-top:2.5em solid #C96259;border-right:2.5em solid transparent;z-index:-10;opacity:.75;}
.wc-bookings-date-picker .ui-datepicker td.ui-datepicker-current-day a{background:#239e57!important;opacity:1!important;}
.wc-bookings-date-picker .ui-datepicker td.ui-datepicker-other-month{background:#eee;}
.wc-bookings-date-picker .ui-datepicker td.bookable-range .ui-state-default{background:#239e57;color:#fff;}

需要更改为Font Awesome图标的部分是:
.wc-bookings-date-picker .ui-icon-circle-triangle-e{background-image:url(../images/ui-icons_ffffff_256x240.png);background-position:-32px 0;}
.wc-bookings-date-picker .ui-icon-circle-triangle-w{background-image:url(../images/ui-icons_ffffff_256x240.png);background-position:-96px 0;}
以前的" \ f053"
的css内容n next的css内容=" \ f054"
我觉得自己很蠢:(
答案 0 :(得分:0)
这不是愚蠢的。来自font-awesome的图标可能看起来与图像类似,但它们不能以相同的方式工作。
更具体地说,它们的工作方式与文本完全相同。因此,您无法使与背景图像相关的所有功能受益,这些功能可以适合/拉伸容器。
因为它是一种字体,所以你不能在后台使用它。幸运的是,您仍然可以使用伪元素显示它。
解决方案是这样的:
.wc-bookings-date-picker .ui-icon-circle-triangle-e, .wc-bookings-date-picker .ui-icon-circle-triangle-w {
position: relative;
}
.wc-bookings-date-picker .ui-icon-circle-triangle-e::before {
content: "\f053";
font-family: 'FontAwesome';
/* Put here the height of the image */
font-size: 240px;
position: absolute;
left: -32px;
top:0;
}
.wc-bookings-date-picker .ui-icon-circle-triangle-w::before {
content: "\f054";
font-family: 'FontAwesome';
/* Put here the height of the image */
font-size: 240px;
position: absolute;
left: -96px;
top:0;
}
答案 1 :(得分:0)
您必须先重置它们并确保它们设置新的定位上下文:
.wc-bookings-date-picker .ui-icon-circle-triangle-e,
.wc-bookings-date-picker .ui-icon-circle-triangle-w {
background:none;
position:relative;
}
然后重新应用规则以使用新版本(您可以猜测另一个版本):
.wc-bookings-date-picker .ui-icon-circle-triangle-w:before {
content:"\f054";
font-family:FontAwesome;
left:0;
position:absolute;
top:0;
}
根据原始CSS,可能需要一些额外的定位。