内容介绍
![Alt]
(https://yt3.ggpht.com/a/AGF-l7_JOPbXWp3QXZDuk7CCOzxdwpRg8MFJliMx5A=s900-c-k-c0xffffffff-no-rj-mo0)
这个学习资源来自于一个youtuber开的频道, 名字叫做online tutorial(https://www.youtube.com/channel/UCbwXnUipZsLfUckBPsC7Jog/featured), 从第一次无意间系统推送给我他的频道的时候我就被他发的一些自创css style深深吸引, 也借以这个平台来和大家分享一下一些很有用的学习资源。**
简介
今天介绍的是一个同时拥有拥有2个调色板背景图的网页设计
代码
html
<section>
<input type="color" name="">
<div class="box">
<input type="color" name="">
</div>
</section>
两个调色板分别放置在中心与整个屏幕
css文件
body {
margin: 0;
padding: 0;
}
section {
position: relative;
width: 100%;
height: 100vh;
background: #ff0;
}
section .box {
width: 400px;
height: 400px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #fff;
border-radius: 50%;
overflow: hidden;
box-shadow: 0 25px 50px rgba(0, 0, 0, .5);
}
1.这里主要就是将第二个调色板放置在中心位置
input[type="color"] {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
border: none;
outline: none;
}
::-webkit-color-swatch {
border: none;
}
::-webkit-color-swatch-wrapper {
padding: 0;
}
这里主要用意是设计调色板在当前容器的位置border, utline,
pseudo元素:::-webkit-color-swatch和::-webkit-color-swatch-wrapper
今天的分享就到这里啦, 希望大家喜欢:)