如何更改此代码以生成令人敬畏的图标,将其从关闭更改为打开,反之亦然。我的意思是,当侧边栏关闭然后我想使用[fa-align-justify \ f039]真棒图标,当它打开时,我想显示[fa-times \ f00d]真棒图标。
怎么做?
<!DOCTYPE html>
<html lang="en">
<head>
<title>toggleBar</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style.css">
<script>
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js">
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
</head>
<body>
<!-- toggle-sidebar -->
<div id="style-selector">
<div class="style-toggle">
</div>
<div id="style-selector-container">
<div class="style-selector-wrapper">
<h1>Content goes here!</h1>
</div>
</div>
</div>
<script type="text/javascript">
jQuery( document ).ready(function() {
if(jQuery('body').hasClass('home')){
jQuery('#style-selector').animate({'right':'0px'},'slow');
} else {
jQuery('body').addClass('ss-open');
jQuery('#style-selector').animate({'right':'-'+jQuery('#style-selector').width()+'px'},'slow');
}
});
jQuery('#style-selector .style-toggle').click(function(e){
e.preventDefault();
if(jQuery('body').hasClass('ss-close')){
jQuery('body').removeClass('ss-close');
jQuery('body').addClass('ss-open');
jQuery('#style-selector').animate({'right':'-'+jQuery('#style-selector').width()+'px'},'slow');
}
else if(jQuery('body').hasClass('ss-open')) {
jQuery('body').removeClass('ss-open');
jQuery('body').addClass('ss-close');
jQuery('#style-selector').animate({'right':'0px'},'slow');
}
else {
jQuery('body').addClass('ss-open');
jQuery('#style-selector').animate({'right':'-'+jQuery('#style-selector').width()+'px'},'slow');
}
}
);
</script>
<!-- end toggle sidebar -->
</body>
</html>
/* STYLE.CSS Toggle Sidebar */
#style-selector {
position: fixed;
right: 0;
top: 0;
z-index: 100000;
-webkit-box-shadow: -3px 0px 50px -2px rgba(0,0,0,0.14);
-moz-box-shadow: -3px 0px 50px -2px rgba(0,0,0,0.14);
box-shadow: -3px 0px 50px -2px rgba(0,0,0,0.14);
background: #fff;
height: 100%;
width: 280px;
}
#style-selector .style-toggle {
width: 52px;
height: 56px;
cursor: pointer;
opacity: 1;
background: #fff;
-moz-border-radius: 5px 0px 0px 5px;
-webkit-border-radius: 5px 0px 0px 5px;
border-radius: 5px 0px 0px 5px;
-webkit-box-shadow: -3px 0px 5px -2px rgba(0,0,0,0.14);
-moz-box-shadow: -3px 0px 5px -2px rgba(0,0,0,0.14);
box-shadow: -3px 0px 5px -2px rgba(0,0,0,0.14);
float: left;
margin-left: -52px;
margin-top: 150px;
top: 100px;
}
#style-selector .style-toggle::before {
color: #f05254;
content: "\f07a";
font-family: fontawesome;
font-size: 23px;
font-weight: lighter !important;
line-height: 56px;
text-align: center;
padding-left: 15px;
}
#style-selector .style-toggle:hover:before {
color: #06a0b0;
}
#style-selector-container {
height: 100%;
overflow-x: hidden;
overflow-y: auto;
-webkit-transition: all 0.5s;
transition: all 0.5s;
padding: 15px;
}
答案 0 :(得分:0)
只需添加content: "\f00d";
,x
在课程ss-close
处于有效状态https://jsfiddle.net/1p2a3jjx/2/时显示.ss-close #style-selector .style-toggle:before{
content: "\f00d";
}
result = [(a, b, d) for (a, b), (c, d) in zip(l1, l2)]