Expression 使之支持css的一些属性

Expression css

经常使用: express

最小高度: 浏览器

最大宽度:#container { width: expression((documentElement.clientWidth > 725) ? "725px" : "auto" ); } 函数

3、让IE6支持min-width同时又支持max-width this

让IE6即支持最小宽度又支持最大宽度限制设置。这种状况咱们经常碰到对图片控制,让不肯定大小的图片,若是太宽,不能超出必定范围值,小的时候不控制他的方法,用到CSS代码: spa

_width:expression(this.scrollWidth > 620 ? "620px" : (this.scrollWidth < 1? "1px" : "auto")); htm


消除嘘线: a {star : expression(this.onFocus=this.blur());} 对象

li:child-first seo

.example l{float:left; margin-left:10px; _margin-left:expression(this.previousSibling==null?'0px':'10px');} 图片

.example li:child-first{margin-left:0;}

 

目录

CSS中的行为—expression

Experssion组合

微软公司产品Expression Studio

编辑本段CSS中的行为—expression

  CSS中使用expressionie才能识别。IE5及其之后版本支持在CSS中使用expression,用来把CSS属性和Javascript表达式关联起来,这里的CSS属性能够是元素固有的属性,也能够是自定义属性。就是说CSS属性后面能够是一段Javascript表达式,CSS属性的值等于Javascript表达式计算的结果。 在表达式中能够直接引用元素自身的属性和方法,也可使用其余浏览器对象。这个表达式就好像是在这个元素的一个成员函数中同样。

  例子:

  1.给元素固有属性赋值

  下面是定义container容器的宽度,若是<725就为本身的宽度,不然就等于725,至关于max-width:725px;。

  <style type="text/css" media="screen">

  #container { width: expression((documentElement.clientWidth > 725) ? "725px" : "auto" ); }

  </style>

  2.给元素自定义属性赋值

  例如,消除页面上的连接虚线框。 一般的作法是:

  <a href="link1.htm" onfocus="this.blur()">link1</a>

  <a href="link2.htm" onfocus="this.blur()">link2</a>

  <a href="link3.htm" onfocus="this.blur()">link3</a>

  粗看或许还体现不出采用expression的优点,但若是你的页面上有几十甚至上百个连接,这时的你难道还会机械式地Ctrl+C,Ctrl+V么,况且二者一比较,哪一个产生的冗余代码更多呢?

  采用expression的作法以下:

  <style type="text/css">

  a {star : expression(this.onFocus=this.blur());}

  </style>

  <a href="link1.htm">link1</a>

  <a href="link2.htm">link2</a>

  <a href="link3.htm">link3</a>

  说明:里面的star就是本身任意定义的属性,你能够随本身喜爱另外定义,接着包含在expression()里的语句就是JS脚本,在自定义属性与expression之间可别忘了还有一个引号,由于实质仍是CSS,因此放在style标签内,而非script内。OK,这样就很容易地用一句话实现了页面中的连接虚线框的消除。不过你先别得意,若是触发的特效是CSS的属性变化,那么出来的结果会跟你的本意有差异。例如你想随鼠标的移进移出而改变页面中的文本框颜色更改,你可能想固然的会认为应该写为

  <style type="text/css">

  input {star : expression(onmouseover=this.style.backgroundColor="#F5F5F5";

  onmouseout=this.style.backgroundColor="#FFFFFF")}

  </style>

  <input type="text">

  <input type="text">

  <input type="text">

  可结果倒是出现脚本出错,正确的写法应该把CSS样式的定义写进函数内,以下所示:

  <style type="text/css">

  input {star : expression(onmouseover=function()

  {this.style.backgroundColor="#FF0000"},

  onmouseout=function(){this.style.backgroundColor="#FFFFFF"}) }

  </style>

  <input type="text">

  <input type="text">

  <input type="text">

  注意:不是很是须要,通常不建议使用expression,由于expression对浏览器资源要求比较高。

相关文章
相关标签/搜索