我正在尝试使用 jQuery 设置边框的宽度,因此它将根据屏幕大小进行调整。
我现在使用的是:
$("#content").css("border-bottom-width", "(1/20)*theHeight", "border-right-width", "(1/10)*theWidth", "border-left-width", "(1/10)*theWidth", "border-top-width", "0");
但这似乎并不能解决问题。我知道值 theHeight 和 theWidth 已填充,所以这不会是问题。
我做错了什么?如果这是一个非常蹩脚的错误,那么我真的很抱歉我是个菜鸟。
最佳答案
应该是这样的:
$("#content").css({"border-bottom-width": (1/20)*theHeight, "border-right-width": (1/10)*theWidth, "border-left-width": (1/10)*theWidth, "border-top-width": 0});
问题是你首先使用了 css() 错误。如果您有多个 css 属性,那么您需要将其设为对象 {key: value, key: value}。其次,如果将变量和计算放在引号中,结果将只是纯文本。
关于jquery - jQuery 中的边框底部宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4213257/