用css如何截取多行文字

html-css09

用css如何截取多行文字,第1张

用php或者其他的截取吧

,css好像只可以隐藏多余的

function

msubstr($str,$start,$len){

for($i=0$i<$start+$len$i++){

$tmpstr=(ord($str[$i])>=161

&&

ord($str[$i])<=247&&

ord($str[$i+1])>=161

&&

ord($str[$i+1])<=254)?$str[$i].$str[++$i]:$tmpstr=$str[$i]

if

($i>=$start&&$i<($start+$len))$tmp

.=$tmpstr

}

return

$tmp

}

这个是php截取类

background:url(pic.jpg) no-repeat left top

后面两个参数就是移动图片位置的,第一个是水平位置,如left或者right或者center,第2个是垂直位置,如top或者bottom或者center,也可以是数字,如

background:url(pic.jpg) no-repeat -10px -20px

具体看你要截取的位置

JS代码(随便放哪里):

<script language="javascript">

<!--

var flag=false

function DrawImage(ImgD){

var image=new Image()

image.src=ImgD.src

if(image.width>0 &&image.height>0){

flag=true

if(image.width/image.height>= 180/110){

if(image.width>180){

ImgD.width=180

ImgD.height=(image.height*110)/image.width

}else{

ImgD.width=image.width

ImgD.height=image.height

}

/*ImgD.alt="bigpic" */

}

else{

if(image.height>110){

ImgD.height=110

ImgD.width=(image.width*110)/image.height

}else{

ImgD.width=image.width

ImgD.height=image.height

}

/*ImgD.alt="bigpic" */

}

}

}

//-->

</script>

图片使用的地方:

<img src="图片" border=0 width="180" height="110" onload="javascriptrawImage(this)">

width="180" height="110" 注意这里最好限定,如果不限定加载图时会成原大,然后再缩小,这个过程如果图大了很难看的.这里是宽度和高度,在前面的JS里改,这里也作相应的改.

图不会变形,只会按比列缩 alt 解决不了.