chr*_*isb 9 html css highlight css3 background-color
我想创建一个类似于用笔制作的高光效果的高光效果.即它有波浪形的顶部和底部以及粗略的开始和结束,如图所示.
在CSS中执行此操作的最佳方法是什么?有没有办法不使用背景图像?此外,它的工作将行换行.
理想情况下,解决方案将采用类似于下面的HTML并使其看起来像图像.
<p>
<span class='green-highlight>So write with a combination of short, medium, and long sentences. Create a sound that pleases the reader's ear. </span>
<span class='pink-highlight'>Don't just write words. </span>
<span class='yellow-highlight'>Write music. </span
</p>
Run Code Online (Sandbox Code Playgroud)
use*_*506 24
一款超逼真的笔荧光笔!使用背景渐变来增强强度并使用文本阴影来赋予其水洗效果。
span {
padding: 0.6em 13.7px;
line-height: 1.8em;
font-size: 23px;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial;
}
span.highlight {
font-weight: bolder;
background: linear-gradient(104deg, rgba(130, 255, 173,0) 0.9%, rgba(130, 255, 173,1.25) 2.4%, rgba(130, 255, 173,0.5) 5.8%, rgba(130, 255, 173,0.1) 93%, rgba(130, 255, 173,0.7) 96%, rgba(130, 255, 1732,0) 98%), linear-gradient(183deg, rgba(130, 255, 173,0) 0%, rgba(130, 255, 173,0.3) 7.9%, rgba(130, 255, 173,0) 15%);
padding: 0.6em 13.7px;
-webkit-box-decoration-break: clone;
margin: 0;
border-radius: 7.5px;
text-shadow: -12px 12px 9.8px rgba(130, 255, 173,0.7), 21px -18.1px 7.3px rgba(255, 255, 255,1), -18.1px -27.3px 30px rgba(255, 255, 255,1);
}Run Code Online (Sandbox Code Playgroud)
<span class="highlight">Lorem Ipsum is simply dummy text of the printing and</span> <span>typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled <span class="highlight">it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was<span>Run Code Online (Sandbox Code Playgroud)
Joh*_*ers 13
仅使用CSS,您可以获得最接近屏幕截图的内容如下:
.green-highlight, .pink-highlight, .yellow-highlight {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding-left: 3px;
}
.green-highlight {
background: #99FFCC; /* Default color, all browsers */
}
.green-highlight::selection {
background: #99CCCC; /* Selection color, WebKit/Blink Browsers */
}
.green-highlight::-moz-selection {
background: #99CCCC; /* Selection color, Gecko Browsers */
}
.pink-highlight {
background: #FFCCFF; /* Default color, all browsers */
}
.pink-highlight::selection {
background: #FF99FF; /* Selection color, WebKit/Blink Browsers */
}
.pink-highlight::-moz-selection {
background: #FF99FF; /* Selection color, Gecko Browsers */
}
.yellow-highlight {
background: #FFFFCC; /* Default color, all browsers */
}
.yellow-highlight::selection {
background: #FFFF66; /* Selection color, WebKit/Blink Browsers */
}
.yellow-highlight::-moz-selection {
background: #FFFF66; /* Selection color, Gecko Browsers */
}Run Code Online (Sandbox Code Playgroud)
<p>
<span class='green-highlight'>
So write with a combination of short, medium,
and long sentences. Create a sound that pleases
the reader's ear.
</span>
<span class='pink-highlight'>
Don't just write words.
</span>
<span class='yellow-highlight'>
Write music.
</span>
</p>Run Code Online (Sandbox Code Playgroud)
如果那还不够,我恐怕你必须使用图像.
Max*_*ann 11
我一直在寻找使用纯 CSS 的最佳效果,并发现 Basecamp 使用的效果非常引人注目。尽管如此,仍有改进的余地。
这是我的改进版本:
这是代码:
mark {
margin: 0 -0.4em;
padding: 0.1em 0.4em;
border-radius: 0.8em 0.3em;
background: transparent;
background-image: linear-gradient(
to right,
rgba(255, 225, 0, 0.1),
rgba(255, 225, 0, 0.7) 4%,
rgba(255, 225, 0, 0.3)
);
-webkit-box-decoration-break: clone;
box-decoration-break: clone;
}Run Code Online (Sandbox Code Playgroud)
Inside this text some words <mark>are highlighted</mark> and some aren’t.Run Code Online (Sandbox Code Playgroud)
如果您对它的工作原理感兴趣:
我写了一个关于如何实现标记笔荧光笔效果的教程。
不使用背景颜色..没有.
背景延伸到元素的边缘,这些边缘总是矩形的(限制border-radius)
在这种情况下,背景图像可能是最佳选择...... 但是:
使用多个text-shadows 可以实现类似的效果.
一个简短的例子.
.green-highlight {
text-shadow:
3px 0px 3px green,
-3px 0px 3px green,
6px 0px 6px green,
-6px 0px 6px green;
}
.red-highlight {
text-shadow:
3px 0px 3px red,
-3px 0px 3px red,
6px 0px 6px red,
-6px 0px 6px red;
}
.yellow-highlight {
text-shadow:
-3px 0px 3px yellow,
3px 0px 3px yellow,
6px 0px 6px yellow,
-6px 0px 6px yellow;
}Run Code Online (Sandbox Code Playgroud)
<p>
<span class="green-highlight">So write with a combination of short, medium, and long sentences. Create a sound that pleases the reader's ear. </span>
<span class="red-highlight">Don't just write words. </span>
<span class="yellow-highlight">Write music. </span
</p>Run Code Online (Sandbox Code Playgroud)
这只需要使用尽可能多的阴影来获得所需的全部效果,
| 归档时间: |
|
| 查看次数: |
7697 次 |
| 最近记录: |