简体   繁体   English

CSS / Javascript-使用css3或javascript复制图像样式(贴纸样式)

[英]CSS/ Javascript - replicate the image style with css3 or javascript (stickers style)

hi is there anyone can give me some advice on how to replicate the image you see into pure css font+style? 嗨,有人可以给我一些建议,如何将您看到的图像复制为纯CSS字体+样式?

在此输入图像描述

i tryed this: JSFIDDLE css 尝试了这个: JSFIDDLE CSS

 *{
        font-family: 'Asap', sans-serif;
        font-size:130px;
        color:#444;
        font-weight:bold;
        letter-spacing:-3px;
    }
    body{
        background:url('http://img.ly/system/uploads/007/221/887/large_antani.png') no-repeat left 190px ;
    }
    img{
        width:auto;
        height:auto;
    }
    a{

        text-shadow:
           3px 3px 0 #fff,
         -1px -1px 0 #fff,  
          1px -1px 0 #fff,
          -1px 1px 0 #fff,
           1px 1px 0 #fff,
            0px 2px 2px #ccc, 0px 4px 4px #ccc,0px 6px 6px #ccc;
    }

html HTML

<a>asd</a>

any suggestion appriciated. 任何建议。

If also you think it's not possible to replicate this please, tell me, cause if not possible i'm wasting time on it, and i will use image instead of pure css . 如果你也认为不可能复制这个,请告诉我,因为如果不可能我会浪费时间,我将使用图像而不是纯粹的css NB: for the text gradient color i know css is not possible, so i'm planning to use somenthing like this : https://github.com/mrnix/pxgradient 注意:对于文本渐变颜色我知道css是不可能的,所以我打算像这样使用somenthing: https//github.com/mrnix/pxgradient

but the huge problem to me it's making the text-shadow appearing as in the image Thanks! 但是对我来说这是一个巨大的问题,它正在使文字阴影出现在图像中谢谢!

I changed your text-shadow to: 我将您的文本阴影更改为:

text-shadow: 0 0 0 20px white, 4px 4px 4px 20px #ccc;

It will only work on browsers that support text-shadow spread (which to my knowledge is just IE10), but it is a closer match to the effect in the image. 它仅适用于支持文本阴影扩散(据我所知仅为IE10)的浏览器,但它与图像效果更接近。

It's not possible to get the gradient from light-blue to slightly-darker-blue in the text colour, unfortunately, so you'll have to pick a solid colour that works best for you. 不幸的是,不可能从文字颜色获得从浅蓝色到稍暗蓝色的渐变,因此您必须选择最适合您的纯色。

Of course, for a cross-browser compatible solution, images are your best bet. 当然,对于跨浏览器兼容的解决方案,图像是您最好的选择。

Personally i think you should go for an image in this case. 我个人认为您应该在这种情况下获取图像。 Definitely for such a simple png, it is not worth the effort imo, and you will have the best cross browser support. 绝对是这样一个简单的png,它不值得努力imo,你将拥有最好的跨浏览器支持。 And I also believe that when it comes to logo's, you need full cross browser compatibility. 而且我也相信,当涉及到徽标时,您需要完全跨浏览器兼容性。 It is what defines your brand, and the way people will recognize you, so no variations should be allowed. 它决定了您的品牌,以及人们认识您的方式,因此不应允许任何变化。

If you insist on 'coding' your logo, I think you should go for an svg for the closest possible match. 如果你坚持对你的徽标进行“编码”,我认为你应该为最接近的匹配找到一个svg。 I would probably replicate the logo in Illustrator (if you do not have it there already) and save it as an svg from there. 我可能会在Illustrator中复制徽标(如果您还没有的话),然后从那里将其另存为svg。 Integrating it in a webpage should be easy then... 将它集成到网页应该很容易...

Here's the closest replica for that image. 这是该图像的最近副本。

Duplicate anchor is needed as -webkit-background-clip: transparent; 需要重复的锚点作为-webkit-background-clip: transparent; clips out the shadow as well while making gradient effect on text. 在对文本进行渐变效果的同时剪切阴影。 Yes, this isn't cross-borwser compatible. 是的,这不是cross-borwser兼容的。

HTML: HTML:

<div class="replica">
    <a class="link">asd</a>
    <a class="shadow">asd</a>
</div>

CSS: CSS:

.replica {
    position: relative;
}
a {
    font-style:italic;
    background: -webkit-gradient(linear, left top, left bottom, from(#99FFFF), to(#0DC4F3));
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
}
a.link {
    position: absolute;
    left:0;
    top:-2px;
    background: -webkit-gradient(linear, left top, left bottom, from(#99FFFF), to(#0DC4F3));
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
}
a.shadow {
    text-shadow: 3px 3px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 0px 2px 2px #ccc, 0px 4px 4px #ccc, 0px 6px 6px #ccc;
}

If you wanted to get crazy and possibly slow down everything, you can use jquery to make a text shadow for every angle. 如果你想变得疯狂并可能减慢一切,你可以使用jquery为每个角度制作文本阴影。

follow this fiddle to try it 按照这个小提琴来试试吧

I just did some jquery to make a shadow for every specific angle... IT IS SLOW, I'm sure even worse with more elements... but there it is. 我只是做了一些jquery为每个特定的角度制作一个阴影......它很慢,我更确定更多的元素...但它确实存在。

function stroke(thisEle) {
    var spread = 10; // how far you want the stroke to be
    var shadows = []; //Start an array for every textshadow
    for(var i = 0; i <= 361; i++){ //For every angle
        var angle = i;
        var pointX = spread*(Math.sin(angle)); //find the direction 
        var pointY = spread*(Math.cos(angle)); //of the text shadow
        if(i == 361){ //Give one last text shadow that is black underneath
            var shadow = '20px 20px 20px black'; 
        } else {
            var shadow = pointX + 'px ' + pointY + 'px 0 white';
        }
        shadows.push(shadow); //Add this shadow to the array
    }

    thisEle.css({
        textShadow: shadows //show all shadows (SLOW)
    });
}

$('a').each(function(){ //for each - do everything above
    var thisEle = $(this);
    stroke(thisEle);  
});

Then, to do the gradient, just follow this tutorial: http://css-tricks.com/snippets/css/gradient-text/ (NOTE CSS3 AND WEBKIT ONLY) 然后,要进行渐变,只需遵循本教程: http ://css-tricks.com/snippets/css/gradient-text/(仅注意CSS3和WEBKIT)

Otherwise, try something like this: http://webdesignerwall.com/tutorials/css-gradient-text-effect 否则,尝试这样的事情: http//webdesignerwall.com/tutorials/css-gradient-text-effect

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM