以前都是在CSDN里面写博客的,也习惯了那里的各种风格,然后听说博客园可以自制css主题,就转来试一下。
想要自制主题首先你得先会HTML和css语言,js会了更好
步骤:
1.首先随意选定一个系统的主题,然后回到博客园首页,右键点击查看网页源代码,这时候你就能看到网页的HTML格式了。
2.你可以把代码复制到自己的编译器上,这样看的时候舒服一点。
3.此时你就可以根据网页的HTML代码,使用各个元素的ID名称或类名给他们设置相应的格式了。
4.但是还是只能设置表现,并不能自己设置页面的结构,有能力的可以搭建一个自己的博客,结构就可以随心所欲了。
附上我网页的css代码,刚开始学css,水平比较菜,写出来的也很low。
我选用的主题是darkgreentrip
#home {
margin: 0 auto;
width: 90%;/*原始65*/
min-width: 980px;/*页面顶部的宽度*/
background-color: rgba(225, 225, 225, 0.4);
padding: 30px;
margin-top: 50px;
margin-bottom: 50px;
box-shadow: 0 2px 6px rgba(100, 100, 100, 0.3);
}
body {
background: #fff url("https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2969707448,4264276642&fm=26&gp=0.jpg") fixed repeat;
background-position:center;
}
#blogTitle h1{
font-family:华文彩云 微软雅黑;
text-align: center;
margin:0;
width:100%;
}
#blogTitle h1 a:hover{
color: blue;
text-decoration: none;
}
#blogTitle h2{
color: gray;
float: right;
width:100px;
}
#navList li a:hover{
background-color: coral;
}
.dayTitle{
font-size: 14px;
}
.dayTitle a{
float: right;
}
.dayTitle a:hover{
color: tomato;
text-decoration: none;
}
.postTitle{
color: rgb(86, 165, 12);
}
.postTitle a:hover{
color:red;
}
.c_b_p_desc {
color: rgb(59, 60, 121);
}
.c_b_p_desc a{color:red}
.c_b_p_desc a:hover{
color: green;
}
#nav_next_page{
border: 2px red solid;
font-weight: bold;
display: inline-block;
}
.catListTitle{
background: pink;
}
#sidebar_search{
display: none;
}
我的点击出心效果,还有背景动态的那些会动的圆点是利用js,代码是我网上搜的,因为我现在还不会js.
点击出心:这个代码需要设置在 博客侧边栏公告(支持HTML代码)下面的代码框
<script type="text/javascript">
(function(window,document,undefined){
var hearts = [];
window.requestAnimationFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback){
setTimeout(callback,1000/60);
}
})();
init();
function init(){
css(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
attachEvent();
gameloop();
}
function gameloop(){
for(var i=0;i<hearts.length;i++){
if(hearts[i].alpha <=0){
document.body.removeChild(hearts[i].el);
hearts.splice(i,1);
continue;
}
hearts[i].y--;
hearts[i].scale += 0.004;
hearts[i].alpha -= 0.013;
hearts[i].el.style.cssText = "left:"+hearts[i].x+"px;top:"+hearts[i].y+"px;opacity:"+hearts[i].alpha+";transform:scale("+hearts[i].scale+","+hearts[i].scale+") rotate(45deg);background:"+hearts[i].color;
}
requestAnimationFrame(gameloop);
}
function attachEvent(){
var old = typeof window.onclick==="function" && window.onclick;
window.onclick = function(event){
old && old();
createHeart(event);
}
}
function createHeart(event){
var d = document.createElement("div");
d.className = "heart";
hearts.push({
el : d,
x : event.clientX - 5,
y : event.clientY - 5,
scale : 1,
alpha : 1,
color : randomColor()
});
document.body.appendChild(d);
}
function css(css){
var style = document.createElement("style");
style.type="text/css";
try{
style.appendChild(document.createTextNode(css));
}catch(ex){
style.styleSheet.cssText = css;
}
document.getElementsByTagName('head')[0].appendChild(style);
}
function randomColor(){
return "rgb("+(~~(Math.random()*255))+","+(~~(Math.random()*255))+","+(~~(Math.random()*255))+")";
}
})(window,document);
</script>
动态背景:设置在页首 HTML 代码
<canvasid="c_n9"width="1920"height="990"style="position: fixed; top: 0px; left: 0px; z-index: -1; opacity: 0.5;"></canvas>
<script src="https://files.cnblogs.com/files/siwuxie095/canvas-nest.min.js"></script>