css如何写出左右是曲线的文本框

html-css012

css如何写出左右是曲线的文本框,第1张

写出左右是曲线的文本框的css写法:

border-radius属性可以实现元素的圆角。如下css可以实现文本框(单行、多行)的圆角:

input[type=text],textarea{border-radius:3pxborder:1px solid #000}

border-radius用法如下:

border-radius 属性是一个简写属性,用于设置四个 border-*-radius 属性。

该属性允许为元素添加圆角边框

语法:

border-radius: 1-4 length|% / 1-4 length|%

按此顺序设置每个 radius 的四个值。

如果省略 bottom-left,则与 top-right 相同。

如果省略 bottom-right,则与 top-left 相同。

如果省略 top-right,则与 top-left 相同。

单位一般用px和百分比较多,其他单位也可

能,一种是使用css样式:先画一条横线或竖线,然后将这条线旋转一定角度得到斜线。代码如下:

<style>

#book{width:300pxheight:20pxborder-bottom:1px solid #000000-webkit-transform: rotate(45deg)/*Safari 4+,Google Chrome 1+ */-moz-transform: rotate(45deg)/*Firefox 3.5+*/filter: progid:DXImageTransform.Microsoft.BasicImage(Rotation=0.45)}</style><div id="book"></div>

另外一种需要使用canvas标签,通过js实现:先画一块画板,再通过两点定位直接在画板上画线。代码如下:

<canvas id="myline" style="width:500pxheight:500px">

</canvas>

<script>

var c=document.getElementById("myline")

var ctx=c.getContext("2d")

ctx.beginPath()

ctx.moveTo(0,0)

ctx.lineTo(300,150)

ctx.stroke()

</script>

<div class="radian"></div>

.radian{

width: 200px

height: 100px

border-radius: 200px/20px/*上下有弧度的边*/

/*border-radius: 20px/200px*//*左右有弧度的边*/

background-color: red

}

border-radius是一种缩写方法。如果“/”前后的值都存在,那么“/”前面的值设置其水平半径,“/”后面值设置其垂直半径。