作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我的任务是制作漂亮的文本,在文本中间加一条白线,如下图所示。是否可以使用 css 来实现?这是 Fiddle
.container{
height:200px;
width:400px;
background-color:#EB8A1C;
}
.container h1{
color:#2CDB1D;
text-align: center;
padding-top:40px;
font-size:400%;
}
<div class="container">
<h1> filosofia </h1>
</div>
最佳答案
你可以用 SVG
做到这一点和 Linear Gradient
.这是另一个 Demo
svg {
border: 1px solid black;
background: #EB8A1C;
}
text {
font-size: 30px;
font-weight: bold;
}
<svg width="250px" height="50px">
<defs>
<linearGradient id="textGradient" x1="0" x2="0" y1="0" y2="1">
<stop offset="0%" stop-color="#A5DE4A" />
<stop offset="45%" stop-color="#A5DE4A" />
<stop offset="50%" stop-color="white" />
<stop offset="60%" stop-color="#A5DE4A" />
<stop offset="100%" stop-color="#A5DE4A" />
</linearGradient>
</defs>
<text fill="url(#textGradient)" x="0" y="35">LOREM IPSUM</text>
</svg>
还有另一种方法可以对具有 position: absolute
的重叠元素执行此操作并修复了 height
最重要的部分是overflow: hidden
在 span
的
@import url(https://fonts.googleapis.com/css?family=Montserrat:700);
.text {
width: 200px;
height: 50px;
padding: 10px;
background: #EB8A1C;
color: white;
position: relative;
display: inline-block;
font-family: 'Montserrat', sans-serif;
font-weight: 700;
}
span {
font-size: 45px;
left: 20px;
position: absolute;
overflow: hidden;
}
span:nth-child(1) {
color: #A5DE4A;
height: 50;
}
span:nth-child(2) {
color: white;
height: 33px;
}
span:nth-child(3) {
color: #A5DE4A;
height: 29px;
}
<div class="text">
<span>filosofia</span>
<span>filosofia</span>
<span>filosofia</span>
</div>
关于html - 中间 CSS 中带有白线的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36155556/
我使用 JavaScript 在 html 5 Canvas 上显示一个数组。该程序对数组中的每个值使用 c.fillRect()。一切看起来都很正常,直到我使用 c.scale() 缩放它。缩放后,
您好! 我正在运行一个博客,使用我自己定制的主题,但我在其中的某些页面上遇到了一个奇怪的问题。主页看起来不受影响,常规页面也不受影响。但是,类别页面会受到此问题的影响。 我的博客在这里:http://
我有一张带有背景图片的图片,将鼠标悬停在它上面会使用 CSS 2D 变换进行缩放和旋转。一切正常,除了 1px 的白色间隙线,看起来很糟糕。这不仅发生在 Chrome 中,而且几乎所有浏览器都会发生。
我有两个 View ,一个叠在另一个上面。 模拟器中的屏幕截图: 我在手机上看到的: 从屏幕上可以看出,模拟器版本很好,但我的手机上有一条两个 View 之间的白线。代码如下: import Reac
我是一名优秀的程序员,十分优秀!