External CSS doesn't work for Cesium infobox popup

1. A concise explanation of the problem you're experiencing.
I want to add html tags in the infobox popup and control their style in my external css file that I have. It was working on previous versions of Cesium.js, but when I upgraded the version of my Cesium.js, it doesn't work anymore.

One other thing is that my external css doesn't work only for the popups and it works perfectly fine for the cesium viewer.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

HTML:
<table id="tbl1">
</table>

CSS:
table#tbl1 {
    position: absolute;
    right: 35px;
    top: 0px;
}

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

4. The Cesium version you're using, your operating system and browser.
I use the client side version of Cesium.js latest version (v1.55).
Browser: Google Chrome

What was the previous version that it worked in? Can you elaborate a bit more on how your app is setup? Are you using a similar structure as the hello world app?

https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Apps/HelloWorld.html

Can you also show how you’re creating the popups?

Hey Omar,

I have a similar question, could you kindly check the following questions. Thanks for your time.

  1. A concise explanation of the problem you’re experiencing.
    I want to control the infobox style in my external CSS file that I have. I start with my application in the Cesium workshop code. I found several discussion pointed out that this could be achieved by modifying the info-box CSS file in Widget, so I create a new CSS file that simlar to the info-box CSS file and I include it in the working directory, however, adding the CSS file is not working. I need to manually add the CSS control in the description. I understand there must be a way to add the CSS file, but I can’t find a better solution. Could you give me some suggestions? Thanks

Cindy

  1. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

Javascript

//load css

var frame = viewer.infoBox.frame;

frame.addEventListener(‘load’, function () {

var cssLink = frame.contentDocument.createElement(‘link’);

cssLink.href = Cesium.buildModuleUrl(‘test.css’);

cssLink.rel = ‘stylesheet’;

cssLink.type = ‘text/css’;

frame.contentDocument.head.appendChild(cssLink);

}, false);

for (var i = 0; i < entities.length; i++) {

var entity = entities[i];

entity.description=

\

.cesium-infoBox-defaultTable th {\

font-weight: normal;\

padding: 10px;\

vertical-align: middle;\

text-align: center;\

}\

.cesium-infoBox-defaultTable td {\

padding: 10px;\

vertical-align: middle;\

text-align: center;\

}\

.cesium-infoBox-description {\

font-family: sans-serif;\

font-size: 17px;\

padding: 4px 10px;\

margin-right: 4px;\

color: #edffff;\

}\

.cesium-infoBox-title {\

display: block;\

height: 20px;\

padding: 5px 30px 5px 25px;\

background: rgba(84, 84, 84, 1.0);\

border-top-left-radius: 7px;\

text-align: center;\

text-overflow: ellipsis;\

white-space: nowrap;\

overflow: hidden;\

box-sizing: content-box;\

}\

\

\ \ \ \ \ \ \ \
TypePower
Name'+"utility pole"+'

}

CSS:

.cesium-infoBox-defaultTable {

width: 100%;

color: #edffff;

}

.cesium-infoBox-defaultTable tr:nth-child(odd) {

background-color: rgba(84, 84, 84, 0.8);

}

.cesium-infoBox-defaultTable tr:nth-child(even) {

background-color: rgba(84, 84, 84, 0.25);

}

.cesium-infoBox-defaultTable th {

font-weight: normal;

padding: 10px;

vertical-align: middle;

text-align: center;

}

.cesium-infoBox-defaultTable td {

padding: 10px;

vertical-align: middle;

text-align: center;

}

  1. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I just want to modify the css style for the infobox.

  1. The Cesium version you’re using, your operating system and browser.
    I use the cesium workshop
    Browser: Google Chrome

Can you show how you’re adding the CSS file that isn’t working? If you can reproduce the issue in an environment like CodePen (https://codepen.io/) that would help a lot.