html分割线

html分割线,第1张

一、普通

1、横线

2、居中横线

<hr align=center width=300 color=#987cb9 size=1>

align 线条位置(可选left、right、center);width线条长度;color颜色;size厚度

二、特效(效果并不是孤立的,可相互组合)

1、两头渐变透明

<hr style="filter: alpha(opacity=100, finishopacity=0, style=3)" width="80%" color=#987cb9 SIZE=3>

2、纺锤形

<HR style="FILTER: alpha(opacity=100,finishopacity=0,style=2)" width="80%" color=#987cb9 SIZE=10>

3、右边渐变透明

<HR style="FILTER: alpha(opacity=100,finishopacity=0,style=1)" width="80%" color=#987cb9 SIZE=3>

4、左边渐变透明

<HR style="FILTER: alpha(opacity=0,finishopacity=100,style=1)" width="80%" color=#987cb9 SIZE=3>

5、虚线

<HR style="border:1 dashed #987cb9" width="80%" color=#987cb9 SIZE=1>

6、双线

<HR style="border:3 double #987cb9" width="80%" color=#987cb9 SIZE=3>

7、立体效果

<HR style="FILTER: progid:DXImageTransform.Microsoft.Shadow(color:#987cb9,direction:145,strength:15)" width="80%" color=#987cb9 SIZE=1>

8、钢针效果

<HR style="FILTER: progid:DXImageTransform.Microsoft.Glow(color=#987cb9,strength=10)" width="80%" color=#987cb9 SIZE=1>

9、垂直分割线

<table border="1px" cellpadding="0" cellspacing="0" style="height:265pxborder-left-style:solidborder-bottom-style:noneborder-right-style:noneborder-top-style:none">

具体有两种方法:

1、画虚线的图,然后插入网页中。缺点是这个虚线不能随意变动大小,因为拉伸图片会产生失真。

2、编程<div style="width:200pxheight:0pxborder-top:1px black dashed" />。缺点,不能改变方向。

可以用svg,可以随意改变大小,粗细,方向,例子如下:

<html>

<head>

</head>

</head>

<body>

<svg

xmlns:dc="http://purl.org/dc/elements/1.1/"

xmlns:cc="http://creativecommons.org/ns#"

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:svg="http://www.w3.org/2000/svg"

xmlns="http://www.w3.org/2000/svg"

version="1.1"

width="500"

height="500"

id="svg2">

<defs

id="defs4" />

<metadata

id="metadata7">

<rdf:RDF>

<cc:Work

rdf:about="">

<dc:format>image/svg+xml</dc:format>

<dc:type

rdf:resource="http://purl.org/dc/dcmitype/StillImage" />

<dc:title></dc:title>

</cc:Work>

</rdf:RDF>

</metadata>

<g

transform="translate(0,-552.36218)"

id="layer1">

<path

d="m 68.571428,651.6479 239.999992,0"

id="path2985"

style="fill:nonestroke:#000000stroke-width:1stroke-linecap:buttstroke-linejoin:miterstroke-miterlimit:4stroke-opacity:1stroke-dasharray:1, 3stroke-dashoffset:0" />

</g>

</body>

</html>

缺点是不能直接在IE里用,火狐、Chrome等都没问题。

除了这些方法外还可以用canvas画虚线。

直接用图片的时候可以考虑用背景图片,这样就可以使用背景的repeat方式无限延长。

无论是用border还是图片都可以使用css3的transform属性设置方向和其他变形。

使用svg或canvas都可以更灵活改变虚线的方向等显示方式。

如果要考虑兼容低版本IE浏览器,当然是用border属性或图片背景兼容性最好,其他方式都需要另外引用js才能兼容。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/6157415.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-03-16
下一篇2023-03-16

发表评论

登录后才能评论

评论列表(0条)

    保存