好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

css伪类 右下角点击出现 对号角标表示选中的示例代码

效果:

css:

.s_ty PE  {
    border: none;
    border-radius: 5px;
    background-color:  # f3f3f3;
    padding: 7px 0;
    color: #606266;
    m arg in: 5px 2.5% 5px 0;
    width: 30%;
    pos IT ion: relative;
}

.selecd {
    background-color: #ebf3ff;
    color: #5999 fc ;
}

.select {
    background-color: #ebf3ff;
    color: #5999fc;
}

.select:before {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    border: 9px solid #5999fc;
    border -t op-color: transparent;
    border-left-color: transparent;
}

ht ML :

<button class="s_type">全部</button>
<button class="s_type">2020年夏季</button>

js:

$(’.s_type’).on(‘click’,function(){
$(this).toggleClass(‘select’);
});

1:设计好按钮本身的样式(.s_type)
2:将要加的样式另写一个类名(.selecd )
3:通过 点击事件 将元素添加样式

刚 开始 想过挺多方法的,比如直接在 伪类 里content: ‘✔’;但这样的话出的效果就是对号没有 背景颜色 ,直接白了 一块 ,这样不行。还想到要不直接把UI的图抠出来,当背景 或者 图片直接浮在按钮上面,后面想想这样不太对。然后我就先去做别的功能,把其他功能写出来再弄这个。就刚好看到一篇 文章 跟我需要的功能一样,就直接按照这篇博客写了。。。然后效果出来了哈哈哈哈

后面去看UI库之类的发现 QQ 的UI库还有专门角标设计( 地址 )

附录:下面看下css 选中框样式

在项目中经常 会用 到下图样式的选中样式
&nbs p;


 

在网上找了一下,思路其实就是对矩形进行 变形 处理,通过伪元素实现 下标 css样式:

.select {
		position: relative;
		width:81px;
		h ei ght:93px;
		mar gin : 0 auto;
		text-align:  center ;
		line-height: 93px;
		color: #4ABE84;
		background-color: #fff;
		box -s hadow:0px 2px 7px 0px rgba(85,110,97,0.35);
		border-radius:7px;
		border:1px solid rgba(74,190,132,1);
	}
	.select:before {
		content: '';
		position: absolute;
		right: 0;
		bottom: 0;
		border: 17px solid #4ABE84;
		border-top-color: transparent;
		border-left-color: transparent;
	}
	.select :after  {
		content: '';
		width: 5px;
		height: 12px;
		position: absolute;
		right: 6px;
		bottom: 6px;
		border: 2px solid #fff;
		border-top-color: transparent;
		border-left-color: transparent;
		transform: rotate(45 deg );
	}

然后是我们通过使用div来展示效果:

<div class="select">测试</div>

完成。

到此这篇关于css伪类 右下角 点击出现 对号角标表示选中的示例代码的文章就介绍到这了,更多相关css右下角对号角标内容请搜索以前的文章或继续浏览下面的相关文章,希望大家以后多多支持!

总结

以上是 为你收集整理的 css伪类 右下角点击出现 对号角标表示选中的示例代码 全部内容,希望文章能够帮你解决 css伪类 右下角点击出现 对号角标表示选中的示例代码 所遇到的问题。

如果觉得 网站内容还不错, 推荐好友。

查看更多关于css伪类 右下角点击出现 对号角标表示选中的示例代码的详细内容...

  阅读:31次