CSS3是一种用于设计网页布局和样式的技术语言,它有着丰富的效果和样式。下面我们来介绍一种使用CSS3来画电池图案的方法。.battery{ width: 60px; height: 32px; bo...
CSS3是一种用于设计网页布局和样式的技术语言,它有着丰富的效果和样式。下面我们来介绍一种使用CSS3来画电池图案的方法。
.battery{
width: 60px;
height: 32px;
border: 1px solid #CCC;
border-radius: 8px;
position: relative;
overflow: hidden;
background: #FFF;
}
.battery:after{
content: "";
display: block;
width: 16px;
height: 16px;
background: #FFCC33;
position: absolute;
top: 50%;
right: -8px;
border-radius: 50%;
transform: translateY(-50%);
box-shadow: -2px 2px 3px rgba(0,0,0,0.2);
}
.battery:before{
content: "";
display: block;
width: 22px;
height: 14px;
background: #666;
position: absolute;
top: 50%;
left: -23px;
border-radius: 0 8px 8px 0;
transform: translateY(-50%);
box-shadow: inset 0 -1px 2px rgba(0,0,0,0.2);
}
.battery:after, .battery:before{
content: "";
display: block;
position: absolute;
bottom: 1px;
left: 1px;
right: 1px;
top: 1px;
border: 1px solid #CCC;
border-radius: 8px;
}
.battery .battery-inner{
width: 100%;
height: 100%;
border-radius: 8px;
background: linear-gradient(to bottom, #66FF33, #33CC33);
position: relative;
}
.battery .battery-inner:before{
content: "";
display: block;
width: 48px;
height: 28px;
position: absolute;
top: 2px;
left: 2px;
box-shadow: inset -1px -1px 1px rgba(0,0,0,0.2), inset 1px 1px 1px rgba(255,255,255,1);
background: linear-gradient(135deg, rgba(255,255,255,0.3) 0, rgba(255,255,255,0) 20px);
border-radius: 4px;
}
.battery .battery-inner:after{
content: "";
display: block;
width: 4px;
height: 8px;
background: #FFF;
position: absolute;
top: 12px;
left: 50%;
border-radius: 4px;
transform: translateX(-50%);
}
.battery .battery-inner:before, .battery .battery-inner:after{
content: "";
display: block;
position: absolute;
bottom: 1px;
left: 1px;
right: 1px;
top: 1px;
border: 1px solid #CCC;
border-radius: 8px;
} 这是一个通过CSS3绘制电池样式的代码。可以参考这个代码来绘制电池,可以根据需要进行调整。