纯css写的各种小按钮合集,记录下来成为学习笔记

button {

background: transparent;

border: 0;

border-radius: 0;

text-transform: uppercase;

font-weight: bold;

font-size: 20px;

padding: 15px 50px;

position: relative;

}

button:before {

transition: all 0.8s cubic-bezier(0.7, -0.5, 0.2, 2);

content: ‘’;

width: 1%;

height: 100%;

background: mistyrose;

position: absolute;

top: 0;

left: 0;

}

button span {

mix-blend-mode: darken;

}

button:hover:before {

background: mistyrose;

width: 100%;

}

一看就能懂啦,主要说一下

在这里插入图片描述

↑没用这个属性。那么通过z-index来调整只能够要么背景盖住图片,要么图片在背景之前。亦或是改变透明度这样并不好。所以使用mix-blend-mode属性。

在这里插入图片描述

闪烁一下按钮

=====================================================================

在这里插入图片描述

html

Hover me

css

#shiny-shadow {

display: flex;

align-items: center;

justify-content: center;

height: 100vh;

background: #1c2541;

}

button {

border: 2px solid white;

background: transparent;

text-transform: uppercase;

color: white;

padding: 15px 50px;

outline: none;

overflow: hidden;

position: relative;

}

span {

z-index: 20;

}

button:after {

content: ‘’;

display: block;

position: absolute;

top: -36px;

left: -100px;

background: white;

width: 50px;

height: 125px;

opacity: 20%;

transform: rotate(-45deg);

}

button:hover:after {

left: 120%;

transition: all 600ms cubic-bezier(0.3, 1, 0.2, 1);

-webkit-transition: all 600ms cubic-bezier(0.3, 1, 0.2, 1);

}

不在赘述 巧用before 通过变幻属性来达到效果。

顺便介绍一个滚动条

========================================================================

html

css

.test {

width : 50px;

height : 200px;

overflow: auto;

float : left;

margin : 5px;

border : none;

}

.scrollbar {

width : 30px;

height: 300px;

margin: 0 auto;

}

.test::-webkit-scrollbar {

/滚动条整体样式/

width : 10px; /高宽分别对应横竖滚动条的尺寸/

height: 1px;

}

.test::-webkit-scrollbar-thumb {

/滚动条里面小方块/

border-radius: 10px;

box-shadow : inset 0 0 5px rgba(0, 0, 0, 0.2);

background : #535353;

}

.test::-webkit-scrollbar-track {

/滚动条里面轨道/

box-shadow : inset 0 0 5px rgba(0, 0, 0, 0.2);

border-radius: 10px;

background : #ededed;

}

/* 蓝色的滚条 */

.test-5::-webkit-scrollbar {

/滚动条整体样式/

width : 10px; /高宽分别对应横竖滚动条的尺寸 width是竖滚动条/

height: 1px;

}

.test-5::-webkit-scrollbar-thumb {

/滚动条里面小方块/

border-radius : 10px;

background-color: skyblue;

background-image: -webkit-linear-gradient(

45deg,

rgba(255, 255, 255, 0.2) 25%,

transparent 25%,

transparent 50%,

rgba(255, 255, 255, 0.2) 50%,

rgba(255, 255, 255, 0.2) 75%,

transparent 75%,

transparent
读者福利

========

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

由于篇幅过长,就不展示所有面试题了,想要完整面试题目的朋友(另有小编自己整理的2024大厂高频面试题及答案附赠)


  • 19
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用伪类和CSS属性来实现轮播图数字按钮的效果。 首先,创建一个容器来包含轮播图和数字按钮。然后,为每个数字按钮创建一个a标签,并设置一个data属性来标识它们的顺序。例如: ```html <div class="slider-container"> <div class="slider"></div> <div class="number-buttons"> <a href="#" data-slide="1"></a> <a href="#" data-slide="2"></a> <a href="#" data-slide="3"></a> </div> </div> ``` 接下来,为每个数字按钮设置CSS样式,可以使用伪类和CSS属性来实现: ```css .number-buttons a { display: inline-block; width: 10px; height: 10px; margin: 0 5px; border-radius: 50%; border: 2px solid #ccc; } .number-buttons a.active, .number-buttons a:hover { border-color: #333; } .number-buttons a:before { content: attr(data-slide); display: block; text-align: center; line-height: 10px; color: #ccc; font-size: 8px; } .number-buttons a.active:before { color: #333; } ``` 在上面的代码中,我们使用了伪类:before来添加数字文本标识,并使用data属性来设置按钮的顺序。我们还使用了:hover和.active来设置数字按钮的激活状态。 最后,使用JavaScript来控制轮播图的切换,当轮播图切换时,通过添加或删除.active类来更新数字按钮的状态。 ```javascript var slider = document.querySelector('.slider'); var numberButtons = document.querySelectorAll('.number-buttons a'); function setActiveButton(index) { // Remove active class from all buttons numberButtons.forEach(function(button) { button.classList.remove('active'); }); // Add active class to button at index numberButtons[index].classList.add('active'); } // Add event listeners to number buttons numberButtons.forEach(function(button, index) { button.addEventListener('click', function(event) { event.preventDefault(); // Set active button and slide to corresponding index setActiveButton(index); slider.style.transform = 'translateX(' + (-100 * index) + '%)'; }); }); ``` 以上就是使用CSS实现轮播图数字按钮的方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值