文本 Text文本对齐 Text Alignweb 内容大部分都是文本。 CSS 里面的 text-align 属性可以控制文本的对齐方式。text-align: justify; 将文本隔开,使每行
顺晟科技
2022-09-15 21:14:18
198
.cover {
padding: 36% 50%;
background: linear-gradient(to right, white 50%, black calc(50% + 1px));
position: relative;
font-size: 200%;
}
.cover::before,
.cover::after {
content: \'\';
position: absolute;
width: 36%; height: 50%;
border-radius: 50%;
left: 50%;
transform: translateX(-50%);
}
.cover::before {
top: 0;
background: radial-gradient(circle, white 13%, black calc(13% + 1px));
}
.cover::after {
bottom: 0;
background: radial-gradient(circle, black 13%, white calc(13% + 1px));
}
.cover-h,
.cover-p {
position: absolute;
mix-blend-mode: difference;
left: 0; right: 0;
text-align: center;
color: #fff;
z-index: 1;
}
<div class="cover">
<h2 class="cover-h">CSS创意与视觉表现</h2>
</div>
.shape-left {
float: left;
width: 200px; height: 500px;
shape-outside: polygon(0 0, 100% 0, 0% 100%);
}
.shape-right {
float: right;
width: 200px; height: 500px;
shape-outside: polygon(100% 0, 100% 100%, 0 100%);
}
.content {
display: block;
padding: 1px;
position: relative;
z-index: 0;
}
.content::before {
content: \'\';
position: absolute;
background-color: #fff;
transform: skewX(-22deg);
left: 50px; right: 50px; top: 0; bottom: 0;
border: 1px solid #ddd;
z-index: -1;
}
<div class="shape-left"></div> <div class="shape-right"></div> <content class="content"> ...内容... </content>
.square {
display: inline-block;
padding: 300px;
background-color: #fff;
background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%), linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%);
background-size: 16px 16px;
background-position: 0 0, 8px 8px;
}
<div class="square"></div>
.clip-img-x {
display: inline-block;
overflow: hidden;
position: relative;
}
.clip-img {
display: block;
}
.clip-shape {
width: 150px; height: 150px;
outline: 9999px solid rgba(0,0,0,.5);
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
margin: auto;
cursor: move;
}
<div class="clip-img-x">
<div class="clip-shape"></div>
<img src="./mm.jpg" class="clip-img">
</div>
.guide-x {
text-align: center;
padding: 100px 16px;
background-color: #fff;
position: relative;
overflow: hidden;
}
.guide-overlay {
position: absolute;
left: 0; top: 0; right: 0; bottom: 0;
background: linear-gradient(transparent, transparent);
}
.guide-overlay-shape {
width: 100px; height: 60px;
position: absolute;
left: 0; top: 0; right: 0; bottom: 0;
margin: auto;
border-radius: 50%;
box-shadow: 0 0 0 9999px rgba(0,0,0,.75);
}
<div class="guide-x">
<div class="guide-overlay">
<i class="guide-overlay-shape" data-content="发布按钮搬到这里了"></i>
</div>
<button class="button">发布</button>
</div>
.tab-x {
display: flex;
flex-direction: row-reverse;
justify-content: flex-end;
padding-left: 20px;
border-bottom: 1px solid rgba(0,0,0,.1);
}
.tab-a {
--backgroundColor: #fff;
background-color: var(--backgroundColor);
line-height: 20px;
padding: 10px 20px;
border-radius: 16px 16px 0 0;
filter: drop-shadow(0 -1px 1px rgba(0,0,0,.1));
position: relative;
}
/* 创建外侧圆弧 */
.tab-a::before,
.tab-a::after {
content: \'\';
position: absolute;
bottom: 0;
width: 16px; height: 16px;
}
.tab-a::before {
background: radial-gradient(circle at 0 0, transparent, transparent 16px, var(--backgroundColor) 17px);
right: 100%;
}
.tab-a::after {
background: radial-gradient(circle at 100% 0, transparent, transparent 16px, var(--backgroundColor) 17px);
left: 100%;
}
.tab-a.active {
--backgroundColor: teal;
color: #fff;
z-index: 1;
}
<div class="tab-x">
<a href="javascript:" class="tab-a">选项卡3</a>
<a href="javascript:" class="tab-a">选项卡2</a>
<a href="javascript:" class="tab-a active">选项卡1</a>
</div>
box-shadow实现类似的效果,如下:
.quar-radius {
width: 96px; height: 96px;
border-radius: 0 0 50% 0;
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
box-shadow: 0 0 0 100px teal;
}
<div class="quar-radius"></div>
.shape-hollow-x {
width: 600px;
max-width: 100%;
height: 300px;
background: linear-gradient(red, green);
position: relative;
}
.shape-hollow {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
margin: auto;
background-color: rgba(0,0,0,.75);
/* 实际开发需要-webkit- */
mask: no-repeat center;
mask-image: linear-gradient(black, black), url(./star.svg);
mask-size: cover, 120px 120px;
mask-composite: exclude;
mask-composite: source-out;
}
HTML代码
<div class="shape-hollow-x">
<i class="shape-hollow"></i>
</div>
img.shape-hollow {
/* 动画 */
animation: starIn 2s infinite;
}
@keyframes starIn {
from {
-webkit-mask-size: 100%, 0 0;
mask-size: 100%, 0 0;
}
to {
-webkit-mask-size: 100%, 300% 300%;
mask-size: 100%, 300% 300%;
}
}
.night {
width: 256px; height: 256px;
background: rgba(0,40,140,.6) url(./house-bed.jpg);
background-size: 100%;
background-blend-mode: darken;
filter: brightness(80%) grayscale(20%) contrast(1.2);
}
<div class="night"></div>
.girl {
width: 256px; height: 171px;
background: rgba(238,179,163, .8) url(./mm.jpg);
background-size: 100%;
background-blend-mode: soft-light;
filter: contrast(1.1);
}
<div class="girl"></div>
.sketch {
width: 256px; height: 192px;
background: url(./example.jpg) -2px -2px, url(./example.jpg);
background-size: 258px 194px;
background-blend-mode: difference;
filter: brightness(3) invert(1) grayscale(1);
}
<div class="sketch"></div>
.watercolor {
width: 256px; height: 192px;
position: relative;
overflow: hidden;
}
.watercolor::before {
content: \'\';
display: block;
height: inherit;
background: url(./example.jpg) -2px -2px, url(./example.jpg);
background-size: 100%;
background-blend-mode: difference;
filter: brightness(2) invert(1) grayscale(1);
}
.watercolor::after {
content: \'\';
position: absolute; left: 0; top: 0;
height: inherit; width: inherit;
background: url(./example.jpg) -1px -1px;
background-size: 100%;
mix-blend-mode: multiply;
filter: brightness(1.3) blur(2px) contrast(2);
}
<div class="watercolor"></div>
.pencil {
width: 256px; height: 192px;
position: relative;
overflow: hidden;
}
.pencil::before {
content: \'\';
display: block;
height: inherit;
background: url(./example.jpg) -1px -1px, url(./example.jpg);
background-size: calc(100% + 1px);
background-blend-mode: difference;
filter: brightness(2) invert(1) grayscale(1);
}
.pencil::after {
content: \'\';
position: absolute; left: 0; top: 0;
height: inherit; width: inherit;
background: url(./example.jpg);
background-size: 100%;
}
<div class="pencil"></div>
.pie-simple {
width: 128px; height: 128px;
background-color: white;
border-radius: 50%;
overflow: hidden;
}
.pie-left,
.pie-right {
width: 50%; height: 100%;
float: left;
position: relative;
overflow: hidden;
}
.pie-left::before,
.pie-right::before,
.pie-right::after {
content: \'\';
position: absolute;
width: 100%; height: 100%;
background-color: teal;
}
.pie-left::before {
left: 100%;
transform-origin: left;
transform: rotate(calc(3.6deg * (var(--percent) - 50)));
opacity: calc(99999 * (var(--percent) - 50));
}
.pie-right::before {
right: 100%;
transform-origin: right;
transform: rotate(calc(3.6deg * var(--percent)));
}
.pie-right::after {
opacity: calc(99999 * (var(--percent) - 50));
}
<div class="pie-item">
<p>10%大小</p>
<div class="pie-simple" style="--percent: 10;">
<div class="pie-left"></div>
<div class="pie-right"></div>
</div>
</div>
<div class="pie-item">
<p>40%大小</p>
<div class="pie-simple" style="--percent: 40;">
<div class="pie-left"></div>
<div class="pie-right"></div>
</div>
</div>
<div class="pie-item">
<p>80%大小</p>
<div class="pie-simple" style="--percent: 80;">
<div class="pie-left"></div>
<div class="pie-right"></div>
</div>
</div>
<div class="pie-item">
<p>99%大小</p>
<div class="pie-simple" style="--percent: 99;">
<div class="pie-left"></div>
<div class="pie-right"></div>
</div>
</div>
.pie-spin {
width: 128px; height: 128px;
background-color: white;
border-radius: 50%;
overflow: hidden;
}
.pie-spin-left,
.pie-spin-right {
width: 50%; height: 100%;
float: left;
position: relative;
overflow: hidden;
}
.pie-spin-left::before,
.pie-spin-right::before,
.pie-spin-left::after,
.pie-spin-right::after {
content: \'\';
position: absolute;
width: 100%; height: 100%;
background-color: teal;
}
.pie-spin-left {
opacity: 1;
animation: second-half-show 1.6s steps(1, end) infinite;
}
.pie-spin-left::before {
left: 100%;
transform-origin: left;
animation: spin 1.6s .8s infinite linear;
}
.pie-spin-right::before {
right: 100%;
transform-origin: right;
animation: spin 1.6s infinite linear;
}
.pie-spin-right::after {
animation: second-half-show 1.6s steps(1, end) infinite;
opacity: 1;
}
.pie-spin-left::after {
animation: second-half-hide 1.6s steps(1, end) infinite;
opacity: 0;
}
@keyframes spin {
0% { transform: rotate(0); }
100% { transform: rotate(360deg); }
}
@keyframes second-half-hide {
0% { opacity: 1; }
50%, 100% { opacity: 0; }
}
@keyframes second-half-show {
0% { opacity: 0; }
50%, 100% { opacity: 1; }
}
.pie-spin2 {
width: 128px; height: 128px;
background-color: white;
border-radius: 50%;
overflow: hidden;
}
.pie-spin2-left,
.pie-spin2-right {
width: 50%; height: 100%;
float: left;
position: relative;
overflow: hidden;
}
.pie-spin2-left::before,
.pie-spin2-right::before {
content: \'\';
position: absolute;
width: 100%; height: 100%;
background-color: teal;
}
.pie-spin2-left::before {
left: 100%;
transform-origin: left;
animation: spinWait2 3.2s infinite linear;
}
.pie-spin2-right::before {
right: 100%;
transform-origin: right;
animation: spinWait1 3.2s infinite linear;
}
@keyframes spinWait1 {
0% { transform: rotate(0deg); }
25%, 50% { transform: rotate(180deg); }
75%, 100% { transform: rotate(360deg); }
}
@keyframes spinWait2 {
0%, 25% { transform: rotate(0deg); }
50%, 75% { transform: rotate(180deg); }
100% { transform: rotate(360deg); }
}
<div class="pie-spin">
<div class="pie-spin-left"></div>
<div class="pie-spin-right"></div>
</div>
<div class="pie-spin2">
<div class="pie-spin2-left"></div>
<div class="pie-spin2-right"></div>
</div>
dot-a {
display: inline-block;
height: 1em; line-height: 1;
text-align: left;
vertical-align: -.25ex;
overflow: hidden;
}
dot-a::before {
display: block;
content: \'...\A..\A.\';
white-space: pre-wrap;
animation: dot1 3s infinite step-start both;
}
@keyframes dot1 {
33% { transform: translateY(-2em); }
66% { transform: translateY(-1em); }
}
正在加载中<dot-a>...</dot-a>
dot-b::before {
content: \'...\';
position: absolute;
animation: dot2 3s infinite step-start both;
}
dot-b:after {
content: \'...\';
color: transparent;
}
@keyframes dot2 {
33% { content: \'.\'; }
66% { content: \'..\'; }
}
正在加载中<dot-b></dot-b>
dot-c {
display: inline-block;
width: 3ch;
text-indent: -1ch;
vertical-align: -.25ex;
overflow: hidden;
animation: dot3 3s infinite step-start both;
font-family: Consolas, Monaco, monospace;
}
@keyframes dot3 {
33% { text-indent: 0; }
66% { text-indent: -2ch; }
}
正在加载中<dot-c>...</dot-b>
dot-d::before {
content: \'\';
position: absolute;
width: 2px; height: 2px;
background-color: currentColor;
box-shadow: 4px 0, 8px 0;
animation: dot4 3s infinite step-start both;
margin-top: 1em;
}
dot-d::after {
content: \'...\';
color: transparent;
}
@keyframes dot4 {
33% { box-shadow: none; }
66% { box-shadow: 4px 0; }
}
正在加载中<dot-d></dot-d>
dot-e::before {
content: \'\';
position: absolute;
width: 10px; height: 2px;
padding: 0 2px;
border-left: 2px solid; border-right: 2px solid;
background-color: currentColor;
background-clip: content-box;
box-sizing: border-box;
animation: dot5 3s infinite step-start both;
margin-top: 1em;
}
dot-e::after {
content: \'...\';
color: transparent;
}
@keyframes dot5 {
33% { border-right-color: transparent; background-color: transparent; }
66% { border-right-color: transparent; }
}
正在加载中<dot-e></dot-e>
.flow-colorful {
max-width: 600px;
height: 150px;
background: linear-gradient(to right, red, orange, yellow, green, cyan, blue, purple);
animation: hue 6s linear infinite;
}
@keyframes hue {
from {
filter: hue-rotate(0deg);
}
to {
filter: hue-rotate(360deg);
}
}
<div class="flow-colorful"></div>
.flow-slogon {
font-size: 120px;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-image: linear-gradient(to right, red, yellow, lime, aqua, blue, fuchsia);
animation: hue 6s linear infinite;
}
<h2 class="flow-slogon">第五届CSS大会</h2>
.flow-twill {
padding-right: 30%;
height: calc(1.4142 * 20px);
background: repeating-linear-gradient(45deg, teal, teal 10px, transparent 11px, transparent 19px, teal 20px);
background-clip: content-box;
animation: twill 1s linear infinite;
position: relative;
}
.flow-twill::before {
content: \'\';
position: absolute;
width: 100%; height: 100%;
background: linear-gradient(rgba(0,0,0,.5), hsla(0,0%,100%,.5), rgba(0,0,0,.5));
}
@keyframes twill {
from {
background-position: 0 0;
}
to {
background-position: 0 calc(-1 * 1.4142 * 40px);
}
}
<div class="flow-twill"></div>
.flow-wave {
padding: 5px 0;
}
.flow-wave:hover,
.flow-wave:focus {
background: radial-gradient(circle at 10px -7px, transparent 8px, currentColor 8px, currentColor 9px, transparent 9px) repeat-x,
radial-gradient(circle at 10px 27px, transparent 8px, currentColor 8px, currentColor 9px, transparent 9px) repeat-x;
background-size: 20px 20px;
background-position: -10px calc(100% + 16px), 0 calc(100% - 4px);
animation: waveFlow 1s infinite linear;
}
@keyframes waveFlow {
from { background-position-x: -10px, 0; }
to { background-position-x: -30px, -20px; }
}
<a href="javascript:" class="flow-wave">hover我(移动端按下)</a>
mix-blend-mode:darken改进实现。body {
position: relative;
}
.indicator {
position: absolute;
top: 0; right: 0; left: 0; bottom: 0;
background: linear-gradient(to right top, teal 50%, transparent 50%) no-repeat;
background-size: 100% calc(100% - 100vh);
z-index: 1;
pointer-events: none;
mix-blend-mode: darken;
}
.indicator::after {
content: \'\';
position: fixed;
top: 5px; bottom: 0; right: 0; left: 0;
background: #fff;
z-index: 1;
}
<!-- 在<body>标签内插入指示器元素 --> <div class="indicator"></div>
.scroll {
height: 600px;
perspective: 1px;
position: relative;
background-color: #fff;
-webkit-clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
overflow-x: hidden;
}
.box {
height: 1280px;
transform-style: preserve-3d;
transform: translateZ(-1px);
position: relative;
}
.iphone {
position: absolute; left: 50%;
transform: translate3d(-50%, -120px, -1px) scale(2);
}
.smile, .flower, .music, .pdf {
position: absolute; left: 50%; top: 50%;
background: url(../../201503/mobile_1_layer2.png) no-repeat;
transform: translate3d(-50%, -50%, 0);
}
.smile {
width: 64px; height: 64px;
margin: -400px 0 0 -400px;
}
.flower {
width: 268px; height: 229px;
background-position: 0 -56px;
margin: -320px 0 0 400px;
}
.music {
width: 114px; height: 114px;
background-position: -10px -297px;
margin: -40px 0 0 -300px;
}
.pdf {
width: 130px; height: 120px;
background-position: -10px -423px;
margin: 140px 0 0 500px;
}
/*mobile*/
@media screen and (max-width: 640px) {
.scroll {
height: 400px;
}
.iphone {
transform: translate3d(-50%, -40px, -1px) scale(2);
max-width: 100%;
}
.smile {
margin-left: -200px;
}
.flower {
margin-left: 200px;
}
.pdf {
margin-left: 260px;
}
}
<div class="scroll">
<div class="box">
<img src="./mobile_1_iphone.jpg" class="iphone">
<i class="smile"></i>
<i class="flower"></i>
<i class="music"></i>
<i class="pdf"></i>
</div>
</div>
.column {
overflow: hidden;
}
.column-left {
height: 400px;
background-color: #fff;
position: relative;
float: left;
}
.column-right {
height: 400px;
padding: 16px;
background-color: #eee;
box-sizing: border-box;
overflow: hidden;
}
.resize-save {
position: absolute;
top: 0; right: 5px; bottom: 0; left: 0;
padding: 16px;
overflow-x: hidden;
}
.resize-bar {
width: 200px; height: inherit;
resize: horizontal;
cursor: ew-resize;
opacity: 0;
overflow: scroll;
}
/* 拖拽线 */
.resize-line {
position: absolute;
right: 0; top: 0; bottom: 0;
border-right: 2px solid #eee;
border-left: 1px solid #bbb;
pointer-events: none;
}
.resize-bar:hover ~ .resize-line,
.resize-bar:active ~ .resize-line {
border-left: 1px dashed skyblue;
}
.resize-bar::-webkit-scrollbar {
width: 200px; height: inherit;
}
/* Firefox只有下面一小块区域可以拉伸 */
@supports (-moz-user-select: none) {
.resize-bar:hover ~ .resize-line,
.resize-bar:active ~ .resize-line {
border-left: 1px solid #bbb;
}
.resize-bar:hover ~ .resize-line::after,
.resize-bar:active ~ .resize-line::after {
content: \'\';
position: absolute;
width: 16px; height: 16px;
bottom: 0; right: -8px;
background: url(./resize.svg);
background-size: 100% 100%;
}
}
<div class="column">
<div class="column-left">
<div class="resize-bar"></div>
<div class="resize-line"></div>
<div class="resize-save">
左侧的内容,左侧的内容,左侧的内容,左侧的内容
</div>
</div>
<div class="column-right">
右侧的内容,右侧的内容,右侧的内容,右侧的内容
</div>
</div>
22
2022-09
15
2022-09
15
2022-09
15
2022-09
14
2022-09
13
2022-09