und*_*oid 14 html css ionicons
我正在使用自定义switch
切换(从这里),我想添加一个图标而不是常规文本.当我将Ionicons
代码粘贴到CSS content
属性时,它显示为一个矩形(表示没有找到字符\ font的事实).我如何通过这个?
编辑:我忘了添加,我已经包含了CDN的CSS.
切换CSS:
.onoffswitch {
position: relative;
width: 108px;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block;
overflow: hidden;
cursor: pointer;
border: 2px solid #999999;
border-radius: 30px;
}
.onoffswitch-inner {
display: block;
width: 200%;
margin-left: -100%;
-moz-transition: margin 0.3s ease-in 0s;
-webkit-transition: margin 0.3s ease-in 0s;
-o-transition: margin 0.3s ease-in 0s;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block;
float: left; width: 50%;
height: 40px; padding: 0;
line-height: 38px;
font-size: 14px;
color: white;
font-weight: bold;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.onoffswitch-inner:before {
content: "ON";
padding-left: 10px;
background-color: #FFFFFF;
color: #BABABA;
}
.onoffswitch-inner:after {
content: "\f425"; /* <--------THE ICON GOES HERE */
padding-right: 10px;
background-color: #8035A7;
color: #FFFFFF;
text-align: right;
}
.onoffswitch-switch {
display: block;
width: 41px; margin: -1.5px;
background: #FFFFFF;
border: 2px solid #999999;
border-radius: 50px;
position: absolute;
top: 0;
bottom: 0;
right: 66px;
-moz-transition: all 0.3s ease-in 0s;
-webkit-transition: all 0.3s ease-in 0s;
-o-transition: all 0.3s ease-in 0s;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<p id="impressions_meter_text">Impressions meter</p>
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
cku*_*jer 16
你错过了一个@font-face
导入"Ionicons"字体的.onoffswitch-inner:after
声明,加上声明没有指定font-family: "Ionicons";
.
我从他们的CSS中提取了Ionicons字体声明并将其添加到了一个分叉的jsFiddle中.
小智 7
您省略了font-family属性..当您将字体图标中的代码用于CSS内容属性时,您必须这样做:
.custom-icon:after {
content: "\f425";
font-family: "the name of the font icon you are using";
}
Run Code Online (Sandbox Code Playgroud)
就是这样:P
使用 Ionic V2
要在您的 css 中使用来自https://ionicframework.com/docs/v2/ionicons/ 的ionicons ,您只需要这样做。
.yourclass {
font-family: "Ionicons";
content: "\f3d1";
}
Run Code Online (Sandbox Code Playgroud)
这将打印: <ion-icon name="arrow-forward"></ion-icon>
您可以在以下位置找到十六进制内容:
node_modules/ionic-angular/css/ionic.css:
node_modules/ionic-angular/css/ionic.dark.css
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
38731 次 |
最近记录: |