coisini123

引入CSS

$(\'input[type="text"]\').blur(function () {
    $(\'#div1\').css(\'color\',\'yellow\')//单行css样式
    $(\'#div1\').css({//多行css样式
        \'color\':\'red\',
        \'background\':\'lightblue\',
        "width":"100px"
    })
})

CSS位置

1.offset() 获取匹配元素在当前视口的相对偏移。

 
var p = $("p:last");
var offset = p.offset();
p.html( "left: " + offset.left + ", top: " + offset.top )

2.position() 获取匹配元素相对父元素的偏移

 
var p = $("p:last");
var offset = p.offset();
p.html( "left: " + offset.left + ", top: " + offset.top );

3.scrollTop() 获取元素相对滚动条顶部的偏移

 

var p = $("p:first");
$("p:last").text( "scrollTop:" + p.scrollTop() );

4.height()

 

$("p").height(20); //段落高度设置为20px

5.width()

取得第一个匹配元素当前计算的宽度值(px)

$("p").width(20);  //段落所有宽度设置为20px

 

分类:

技术点:

相关文章:

  • 2021-11-30
  • 2021-10-02
  • 2022-02-11
  • 2022-01-06
  • 2021-12-05
  • 2022-02-23
  • 2022-12-23
猜你喜欢
  • 2022-01-31
  • 2021-09-29
  • 2022-12-23
  • 2021-12-09
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案