<!-- 1、使用 border -->
<div class="border">border 实现</div>
<!-- 2、使用伪元素 -->
<div class="pesudo">伪元素实现</div>
<!-- 3、外 box-shadow -->
<div class="boxShadow">外 box-shadow 实现</div>
<!-- 4、内 box-shadow -->
<div class="insertBoxShadow">内 box-shadow 实现</div>
<!-- 5、drop-shadow -->
<div class="filterDropShadow">drop-shadow 实现</div>
<!-- 6、渐变 -->
<div class="linearGradient">线性渐变实现</div>
<!-- 7、outline -->
<div class="outline">outline 实现</div>
<!-- 8、滚动条 -->
<div class="scroll"></div>
<!-- 9、texr-decoration -->
<div class="textDecoration">texr-decoration</div>
<!-- 10、first-letter -->
<div class="fitstLetter">1</div>
<!-- 11、list-style -->
<div class="listStyle"></div>
<!-- <div class="listStyle2">11223344</div> -->
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@1,300&display=swap");
html,
body {
width: 100%;
height: 100%;
display: flex;
flex-wrap: wrap;
}
div {
flex-shrink: 0;
font-family: "Open Sans", sans-serif;
position: relative;
width: 200px;
height: 60px;
line-height: 60px;
margin: 20px;
background: #ddd;
text-align: center;
}
.border {
border-left: 5px solid deeppink;
}
.pesudo::after {
content: "";
width: 5px;
height: 60px;
position: absolute;
top: 0;
left: 0;
background: deeppink;
}
.boxShadow {
margin-left: 25px;
box-shadow: -5px 0px 0 0 deeppink;
}
.insertBoxShadow {
box-shadow: inset 5px 0px 0 0 deeppink;
}
.filterDropShadow {
margin-left: 25px;
-webkit-filter: drop-shadow(-5px 0 0 deeppink);
}
.linearGradient {
background-image: linear-gradient(
90deg,
deeppink 0px,
deeppink 5px,
transparent 5px
);
}
.outline {
margin-left: 25px;
height: 50px;
outline: 5px solid deeppink;
}
.outline:after {
position: absolute;
content: "outline实现";
top: -5px;
bottom: -5px;
right: -5px;
left: 0;
background: #ddd;
}
.scroll {
position: relative;
width: 205px;
background: deeppink;
overflow-y: scroll;
}
.scroll::-webkit-scrollbar {
width: 200px;
background-color: #ddd;
}
// 下划线实现
.textDecoration {
overflow: hidden;
&::before {
position: absolute;
content: "_______";
font-size: 40px;
bottom: 30px;
left: -15px;
text-decoration: underline;
color: deeppink;
line-height: 60px;
transform: rotate(90deg);
right: 142px;
}
}
.fitstLetter {
position: relative;
overflow: hidden;
&::first-letter {
background: deeppink;
color: transparent;
width: 5px;
position: absolute;
left: 0;
top: 0;
padding: 34px 0px;
margin-left: -196px;
}
&::before {
content: "::first-letter 实现";
position: absolute;
top: 0;
left: 0;
right: 0;
}
}
.listStyle {
position: relative;
display: list-item;
list-style: square inside;
padding-left: 5px;
line-height: 0;
font-size: 600px;
overflow: hidden;
background: deeppink;
color: #ddd;
&::before {
content: "list-style 实现";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
color: #000;
font-size: 16px;
line-height: 60px;
z-index: 1;
}
}
.listStyle2 {
position: relative;
display: list-item;
list-style-type: square;
list-style-position: inside;
padding-left: 5px;
line-height: 60px;
font-size: 20px;
overflow: hidden;
background: deeppink;
color: #ddd;
animation: scale 5s infinite linear;
}
@keyframes scale {
0%,
30% {
font-size: 20px;
}
80%,
100% {
font-size: 600px;
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.