doumor942473 2017-04-18 10:08
浏览 28
已采纳

我的跨度有什么区别?

I have two spans inside my echo:

echo '<div class="elementsDiv" id="'.$row['objekt_nr']."_".$row['element_nr'].'" data-weight="'.$row['vikt'].'"  data-nr="'.$row['element_nr'].'" style="width: '.$langd.'px; height: '.$bredd.'px;><span class="elementDivNr">'.$row['element_nr'].'</span><span class="elementDivWeight">'.round($viktT, 2).' t</span></div>';

Span with class: "elementDivNr" & span with class: "elementDivWeight".

I try to set a background color for the spans with CSS:

span.elementDivNr{
  background-color: red !important;
}
span.elementDivWeight{
  background-color: red !important;
}

Now... why is only one of them getting the red color background? How can I search for "overrides"?

enter image description here

My code is pretty big in both CSS and JS as this is a "DnD" application.

UPDATE
It is strange is that I cannot access this span at all with CSS.

span.elementDivNr{
  background-color: red !important;
  font-size: 14px;
}

Changing font size has no effect either.

UPPDATE

https://jsfiddle.net/1u8evdr8/

  • 写回答

3条回答 默认 最新

  • dongyinting3179 2017-04-18 10:23
    关注

    You are missing a closing " on your style tag of your DIV.

    So this:

    echo '<div class="elementsDiv" id="'.$row['objekt_nr']."_".$row['element_nr'].'" data-weight="'.$row['vikt'].'"  data-nr="'.$row['element_nr'].'" style="width: '.$langd.'px; height: '.$bredd.'px;><span class="elementDivNr">'.$row['element_nr'].'</span><span class="elementDivWeight">'.round($viktT, 2).' t</span></div>';
    

    Should be this:

    echo '<div class="elementsDiv" id="'.$row['objekt_nr']."_".$row['element_nr'].'" data-weight="'.$row['vikt'].'"  data-nr="'.$row['element_nr'].'" style="width: '.$langd.'px; height: '.$bredd.'px;"><span class="elementDivNr">'.$row['element_nr'].'</span><span class="elementDivWeight">'.round($viktT, 2).' t</span></div>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据