开关css样式,按钮样式css3

怎样用CSS写按钮样式

一般有三种方法:

创新互联专注于企业营销型网站建设、网站重做改版、张北网站定制设计、自适应品牌网站建设、H5响应式网站成都做商城网站、集团公司官网建设、外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为张北等各大城市提供网站开发制作服务。

Button标签直接使用CSS定义样式,优点是立体感、有按下状态,缺点是样式单一、各浏览器下显示效果不一致。

a标签+背景图片+滑动门技术,优点是可实现多种视觉效果,缺点是采用滑动门技术会导致背景图片过大。

a标签直接使用CSS3绘制,优点是在保证视觉效果的基础上大大减少了背景图片的使用,缺点是部分浏览器不兼容。

如何使用 css3 制作手机来回拨样式的开关

思路:

给矩形添加圆角,然后添加阴影,添加圆角用border-radius ,添加阴影用box-shadow

css样式选取框

用了JQ库,样式在style里,不过要配合js用

!DOCTYPE html

html

head

meta charset="utf-8"

title/title

script src="jquery-3.3.1.min.js"/script

/head

style

.div1{

text-align: center;

background: beige;

width: 50px;

height: 28px;

border-radius: 14px;

}

.span1{

/* margin-top: 7px; */ /* div的时候打开注释 */

background: #CCCCCC;

width: 13px;

height: 13px;

display: inline-block;

border-radius: 7px;

}

.div2{

text-align: center;

background: lawngreen;

width: 50px;

height: 28px;

border-radius: 14px;

}

.span2{

background: white;

width: 13px;

height: 13px;

display: inline-block;

border-radius: 7px;

}

.hid1{

display: none;

}

.hid2{

}

/style

body

!-- button的 --

button class="div1"

span class="hid1"是/span

span class="span1"/span

span class="hid2"否/span

/button

hr

hr

!-- div的 --

!-- div class="div1"

span class="hid1"是/span

span class="span1"/span

span class="hid2"否/span

/div --

/body

script

$(function(){

$(".div1").click(function(){

$(".span1").toggleClass("span2");

$(".div1").toggleClass("div2");

$(".hid1").toggle();

$(".hid2").toggle();

})

})

/script

/html


网站名称:开关css样式,按钮样式css3
本文来源:http://ybzwz.com/article/dseeoeg.html