div+css实现逼真物理开关按下效果代码
代码语言:html
所属分类:布局界面
代码描述:div+css实现逼真物理开关按下效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { background: linear-gradient(180deg, #efefef 0%, #cdcdcf 100%) no-repeat; height: 100vh; display: flex; flex-flow: row nowrap; justify-content: center; padding: 0; margin: 0; position: relative; } #toggleWrapper { width: 100px; height: 140px; border-radius: 8px; border: solid 1px #fff; border-right-color: #c9c9c9; border-bottom-color: #949494; border-left-color: #bcbcbc; background: linear-gradient(180deg, #efefef 0%, #cccccc 100%); box-shadow: -2px 2px 2px rgba(0, 0, 0, 0.2); box-sizing: border-box; margin: auto; padding: 12px 14px; } #toggleWrapper input { appearance: none; } #toggleWrapper > div { display: flex; flex-flow: column wrap; width: 100%; height: 100%; border: solid 1px #666; border-radius: 8px; box-shadow: 2px -2px 2px 1px rgba(0, 0, 0, 0.1), -2px 0px 2px 1px rgba(0, 0, 0, 0.1); } #toggleWrapper #toggleOn, #toggleWrapper #toggleOff { width: 100%; height: 58px; background: #fff; margin: 0; position: relative; } #toggleWrapper #toggleOn { border-bottom: solid 4px #898989; background: linear-gradient(180deg, #dedede 0%, #eaeaea 100%); border-radius: 0 0 8px 8px; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2), -2px 2px 2px rgba(0, 0, 0, 0.2); margin-top: -2px; } #toggleWrapper #toggleOn:before { content: ""; width: 2px; height: 26px; background: #666; left: 50%; top: 50%; margin: -13px 0 0 -1px; position: absolute; } #toggleWrapper #toggleOn:after { content: ""; bottom: -2px; width: 100%; height: 2px; position: absolute; box-shadow: 0 10px 15px 1px rgba(0, 0, 0, 0.8); } #toggleWrapper #toggleOn:checked { border-bottom: solid 1px #666; background: radial-gradient(cir.........完整代码请登录后点击上方下载按钮下载查看
网友评论0