CSS div文字描边 兼容IE6 IE7 IE8 火狐浏览器

html-css07

CSS div文字描边 兼容IE6 IE7 IE8 火狐浏览器,第1张

<style type="text/css">

body { font-size:12pxfont-family:Arial, Helvetica, sans-serif

filter:alpha(style=1,startY=0,finishY=100,startX=100,finishX=100)

background-color:#666666

}

.sizscolor {

position:absolute

padding:4px

filter:

Dropshadow(offx=1,offy=0,color=white)

Dropshadow(offx=0,offy=1,color=white)

Dropshadow(offx=0,offy=-1,color=white)

Dropshadow(offx=-1,offy=0,color=white)

text-shadow:0 0 1px #FFF

}

</style>

</head>

<body>

<span>ie用滤镜,火狐用css3</span>

<br />

<div class="sizscolor">中文描边效果</div>

</body>

</html>

box-shadow:给元素块添加周边阴影效果。

语法:box-shadow: h-shadow v-shadow blur spread color inset

*还有另一种情况: box-shadow: 0 2px 2px #FECC84

当我们在色值前只写了三个数值的情况下,则第三个值是 blur (模糊距离)。

利用阴影属性,也可以实现外边框的效果:

当我们再为它添加一个 outline (轮廓),就会发现它实现了-边框内圆角:

* 关于为什么会这样:

outline的描边并不会跟着圆角走,因此显示为直角。

所以把这两者叠加到一起,box-shadow 则刚好填补描边与容器圆角之间的空隙。

*值得注意的是,box-shadow 阴影的大小值并不一定等于描边的宽度,它和圆角的大小有关系。所以只需要一个足够填补空隙的大小就可以了。事实上,制定一个等于描边宽度的值在某些浏览器中可能会渲染异常,所以,最好是稍小的值。

参考书籍: Lea Verou 《CSS揭秘》

css5 是何方神圣?

css div描边

border: 1px red solid

有很多参数,自己百度:css border 和 css outline

CSS3文字描边

text-shadow:#000 1px 0 0,#000 0 1px 0,#000 -1px 0 0,#000 0 -1px 0

-webkit-text-shadow:#000 1px 0 0,#000 0 1px 0,#000 -1px 0 0,#000 0 -1px 0

-moz-text-shadow:#000 1px 0 0,#000 0 1px 0,#000 -1px 0 0,#000 0 -1px 0

*filter: Glow(color=#000, strength=1)

html5描边

HTML5 Canvas 填充与描边(Fill And Stroke)

<!DOCTYPE html>  

<html>  

<head>  

<meta http-equiv="X-UA-Compatible" content="chrome=IE8">  

<meta http-equiv="Content-type" content="text/htmlcharset=UTF-8">  

<title>Canvas Fill And Stroke Text Demo</title>  

<link href="default.css" rel="stylesheet" />  

    <script>  

        var ctx = null // global variable 2d context  

        var imageTexture = null  

        window.onload = function() {  

            var canvas = document.getElementById("text_canvas")  

            console.log(canvas.parentNode.clientWidth)  

            canvas.width = canvas.parentNode.clientWidth  

            canvas.height = canvas.parentNode.clientHeight  

              

            if (!canvas.getContext) {  

                console.log("Canvas not supported. Please install a HTML5 compatible browser.")  

                return  

            }  

              

            // get 2D context of canvas and draw rectangel  

            ctx = canvas.getContext("2d")  

            ctx.fillStyle="black"  

            ctx.fillRect(0, 0, canvas.width, canvas.height)  

              

            // fill and stroke text  

            ctx.font = '60pt Calibri'  

            ctx.lineWidth = 3  

            ctx.strokeStyle = 'green'  

            ctx.strokeText('Hello World!', 20, 100)  

            ctx.fillStyle = 'red'  

            ctx.fillText('Hello World!', 20, 100)  

              

            // fill and stroke by pattern  

            imageTexture = document.createElement('img')  

            imageTexture.src = "../pattern.png"  

            imageTexture.onload = loaded()  

        }  

          

        function loaded() {  

            // delay to image loaded  

            setTimeout(textureFill, 1000/30)  

        }  

          

        function textureFill() {  

            // var woodfill = ctx.createPattern(imageTexture, "repeat-x")  

            // var woodfill = ctx.createPattern(imageTexture, "repeat-y")  

            // var woodfill = ctx.createPattern(imageTexture, "no-repeat")  

            var woodfill = ctx.createPattern(imageTexture, "repeat")  

            ctx.strokeStyle = woodfill  

            ctx.strokeText('Hello World!', 20, 200)  

              

            // fill rectangle  

            ctx.fillStyle = woodfill  

            ctx.fillRect(60, 240, 260, 440)  

        }  

          

    </script>  

</head>  

<body>  

    <h1>HTML5 Canvas Text Demo - By Gloomy Fish</h1>  

    <pre>Fill And Stroke</pre>  

    <div id="my_painter">  

        <canvas id="text_canvas"></canvas>  

    </div>  

</body>  

</html>