![](/img/trans.png)
[英]Why does getComputedStyle() in a JEST test return different results to computed styles in Chrome / Firefox DevTools
[英]Chrome DevTools: Computed style different from css rule?
當我在 CSS 文件中定義 4px 時,我的 DOM 元素怎么可能有 0px 的“border-top-width”。
當我使用 Chrome DevTools 檢查元素時,我看到計算的樣式告訴 0px,而最上面的 css 規則是 4px。 它甚至沒有被划掉。
首先我想可能此時沒有加載 CSS 文件,但是當您查看“border-top-color”時,您可以看到它起作用了(設置並顯示了紅色)。
0px 來自哪里,什么覆蓋了我的 CSS 文件設置?
有沒有人在 ChromeDev 工具中看到過這種行為?
編輯:哇你們很快,到目前為止謝謝! 這是 html 元素。 所有計算的 css 屬性都在添加的圖片中。
<div id="PageStyleTest2_MeasurementSystemSelector_styled_ddList_11" data-brease-widget="widgets/brease/ListBox" style="width: 150px; height: 120px;" class="breaseListBox breaseWidget widgets_brease_ListBox_style_default">
<ul>
<li style="height:40px; " data-brease-value="metric"><span>Metrisch</span></li>
<li style="height:40px; " data-brease-value="imperial" class="selected"><span>Imperial</span></li>
<li style="height:40px; " data-brease-value="imperial-us"><span>Imperial U.S.</span></li>
</ul>
</div>
所有計算的 css 樣式:
添加border-style: solid;
到元素的 CSS 將解決這個問題。
(雖然這不是問題的答案,但它確實解決了所提出的示例問題,並且可能是大多數登陸這里的人正在尋找的。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.