I am trying to convert javascript into css styles , I was able to convert into css format but , There was problem . I was unable to remove double quort " or ' symbol.
var out = console.log,
a = {
".time":{
"color":"red",
'background-color':'yellow',
height:'10%',
zindex:1
},
'#next':{
'colour':'#eee'
},
div:{
width:10,
'-webkit-hyphenate-character': 'auto'
},
"@keyframes example" : {
"0%" : {"background-color": 'red'},
"25%" : {"background-color": 'yellow'}
}
}
var toStyles = function(object){
var store = '';
Object.keys(object).forEach(name => {
var value = object[name];
if(typeof value == 'object'){
}
var style = name+':'+JSON.stringify(value)+';';
store = store + style;
});
console.log(store)
}
toStyles(a)
My output:-
.time{
"color":"red",
"background-color":"yellow",
"height":"10%",
"zindex":1
};
#next{
"colour":"#eee"
};
div{
"width":10,
"-webkit-hyphenate-character":"auto"
};
@keyframes example{
"0%":{"background-color":"red"},
"25%":{"background-color":"yellow"}
};
How can i convert objects like this into proper css styles.
Please Help me