热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

渐变H1-使我的H1字体文本为两种不同颜色的渐变-GradientH1-MakemyH1fonttextagradientoftwodifferentcolors

HowdoImakemyh1textagradientfrom#006768to#2E0750.如何使我的h1文本成为#006768到#2E0750的渐变。IuseW

How do I make my h1 text a gradient from #006768 to #2E0750.

如何使我的h1文本成为#006768到#2E0750的渐变。

I use Wordpress.

我使用Wordpress。

I basically want to achieve the following with code:

我基本上想用代码实现以下功能:

http://www.reading-college.ac.uk/sites/default/files/gradient-example.jpg

Can't post an image as lacking enough rep.

无法发布图像缺乏足够的代表。

My site URL is:

我的网站网址是:

http://79.170.44.112/activate-enterprise.co.uk/

I've searched online but can't seem to find a suitable solution?

我在网上搜索但似乎无法找到合适的解决方案?

UPDATE

This is the code I've tried:

这是我试过的代码:

h1.entry-title {
font-size: 72px;
background-image: -webkit-gradient(
linear,
left top,
right top,
color-stop(0.03, rgb(44,7,85)),
color-stop(0.76, rgb(0,103,107))
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}

However it's still not showing on my homepage, rather reverting to #2E0750

但是它仍然没有在我的主页上显示,而是回到#2E0750

SECOND UPDATE

Managed to get it work, since I reduced the font size, I had to change the locations accordingly as you couldn't really see the gradient change.

管理得到它的工作,因为我减少了字体大小,我不得不相应地更改位置,因为你无法真正看到渐变变化。

2 个解决方案

#1


0  

Very possible, check out this JSFiddle from this stackoverflow post.Appears to only work in -webkit- though, so YMMV.

很可能,从这个stackoverflow post检查这个JSFiddle。虽然只是在-webkit-工作,所以YMMV。

h1 {
  font-size: 72px;
  background-image: -webkit-gradient(
    linear,
    left top,
    right top,
    color-stop(0.03, rgb(250,3,3)),
    color-stop(0.52, rgb(240,255,127)),
    color-stop(0.76, rgb(42,24,173))
);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

It makes use of the webkit-gradient CSS3 property.

它使用了webkit-gradient CSS3属性。

#2


0  

You can leverage SVG and some CSS to achieve a Modern Browser compliant version of what you're going for. You'll need your gradient/background image, and some simple CSS on an SVG element and SVG text using the "Pattern" element as your url for the fill.

您可以利用SVG和一些CSS来实现符合您现代浏览器的版本。你需要你的渐变/背景图像,以及SVG元素和SVG文本上的一些简单CSS,使用“Pattern”元素作为填充的url。

Html Elements Below

下面的Html元素



    
        
    

SVG rocks!

CSS Below

svg {
    width: 6em; height: 1.5em;
    font: 900 500%/1.2 'Arial Black', sans-serif;
}

text { fill: url(#rainbow); }

→JS FIDDLE EXAMPLE HERE←

→JS FIDDLE例子在这里←


推荐阅读
author-avatar
奋斗的小鸟
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有