Skip to content

Instantly share code, notes, and snippets.

@coa00
Last active August 29, 2015 14:28
Show Gist options
  • Save coa00/831874062ad7210d2735 to your computer and use it in GitHub Desktop.
Save coa00/831874062ad7210d2735 to your computer and use it in GitHub Desktop.
cssファイル使わずにjavascriptのみで簡単にスタイルをあてる。 ref: http://qiita.com/coa00@github/items/29c6d2b65f1ec19529da
.hoge {
background-color: #fff;
}
.hoge:hover {
border: 1px solid #0097cf;
}
hoge.css
fuga.js
test.js
var css = '<style type="text/css">\
.hoge {\
background-color: #fff;\
}\
.hoge:hover {\
border: 1px solid #0097cf;\
}\
</style>';
$(body).append($('css'));
.hoge {
background-color: #fff;
}
.hoge:hover {
border: 1px solid #0097cf;
}
gulp.task('templates', function(){
var src = "./src/css/";
var dest = src+'templates/build';//出力場所
gulp.src(src+'/*.css')
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'App.css',
noRedeclare: true // Avoid duplicate declarations
}))
.pipe(concat('style.js'))
.pipe(gulp.dest(dest));
});
var css = '<style type="text/css">\
.hoge {\
background-color: #fff;\
}\
.hoge:hover {\
border: 1px solid #0097cf;\
}\
</style>';
$(body).append($('css'));
$("body").append(App.css.style);
$("body").append(App.css.style);
gulp.task('templates', function(){
var src = "./src/css/";
var dest = src+'templates/build';//出力場所
gulp.src(src+'/*.css')
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'App.css',
noRedeclare: true // Avoid duplicate declarations
}))
.pipe(concat('style.js'))
.pipe(gulp.dest(dest));
});
$("body").append(App.css.style);
<style type="text/css">
.hoge {
background-color: #fff;
}
.hoge:hover {
border: 1px solid #0097cf;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment