[英]How to apply “-webkit” css rules using jquery .css
Hey fellas and ladies, 嘿伙计们,女士们,
I'm having an issue applying the following css rule. 我在应用以下CSS规则时遇到问题。
$('#bam').css({"-webkit-overflow-scrolling": "touch"})
Is applying -webkit stuff supported in jquery being a nonstandard rule? 在jQuery中应用-webkit支持的东西是非标准规则吗? When I apply nothing happens and no error occurs.
当我申请时,没有任何反应,也没有错误发生。
However if I do the the same syntax and change color it works. 但是,如果我使用相同的语法并更改颜色,它将起作用。
As a use case im trying to fix an issue with an iphone iframe overflow problem see iframe size with CSS on iOS for my current issue and Im not in a position to use inline styles or external css. 作为一个用例,我正在尝试解决iphone iframe溢出问题,请参阅iOS上iframe大小与CSS有关的当前问题,而我无法使用内联样式或外部CSS。
Any ideas :)? 有任何想法吗 :)?
Added jsbin example. 添加了jsbin示例。
https://jsbin.com/vizacezeva/edit?html https://jsbin.com/vizacezeva/edit?html
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
$( document ).ready(function() {
$('#bam').css({"overflow-scrolling": "touch"})
console.log('hi');
console.log($('#bam').css("overflow-scrolling"));
});
</script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div id="bam" style="width:100%; padding:0px;">
<iframe src="http://www.jsbin.com" style="width:1px; min-width:100%; max-width:100%;">
</iframe>
</div>
</body>
</html>
Instead of adding the CSS rule with jQuery you can declare a rule in your CSS file and add a class which applies the style. 您可以在CSS文件中声明一个规则并添加一个应用样式的类,而不是使用jQuery添加CSS规则。
/** style.css **/
.foo { -webkit-overflow-scrolling: touch; }
// app.js
$('#bam').addClass('foo');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.