熱門文章

2016年10月8日 星期六

[JS]什麼是 element.style ?



我想要修改下圖左側的星星為一行,但是我發現我從更改css width 卻無法變動。
一直看到一個 element.style 的width: 100px;
而css 設定的被阻擋掉了。



後來google找到這篇
https://www.drupal.org/node/229348

element.style is the style that's defines on the element - directly - using style=""
It's the royal flush of element selectors. It's the most specific, un-over-ridable setting.
It's in the source!
so it's coming from the jquery code itself, written in at runtime. And nothing to do with Drupal or your theme for that matter.
You gotta debug jCarousel to find out why it thinks that's a good size. Maybe its calculations are wrong, or maybe it's just hard-coded some padding it thinks looks beter.
You should have seen it in the DOM inspector.

大意就是說這個寬度是由 jquery 即時產生的,所以覆蓋掉css的寬度設定。只能從原本的jquery檔案裡面去更動。
jquery.raty.js 底下,後來在102行找到,將寬度乘上3倍!


更改後的樣子








沒有留言:

張貼留言