I have a style sheet that is used to display server status text and a colored bar (green = good, red = down, yellow = maintenance).
The way I have these set up are:
#status.Normal{
color: white;
text-align: left;
font-size:17px;
font-weight:700;
letter-spacing:1px;
background: url(images/greenbar.jpg) no-repeat;
}
#status.Down{
color: white;
text-align: left;
font-size:17px;
font-weight:700;
letter-spacing:1px;
background: url(images/red.jpg) no-repeat;
}
And the way they are used is just by declaring Normal or Down in my server list xml file.
For example, if the site status was normal for a site the xml would read:
<site name="template">
<title>Title</title>
<systemStatus>Normal</systemStatus>
<networkNotes>notes etc</networkNotes>
<maintenanceInformation>
information about maintenance etc.
</maintenanceInformation>
</site>
The HTML where this is used:
<td>
<tr><td id="status"></td></tr>
</td>
The HTML reads from the "status" in the XML and the site would get the "Normal" and the green bar and show those as the status for that server based on the CSS.
Is there a way, with my current setup, to declare a new property in the css (translating to French for French users currently) where I can make the new property (for "Down") as:
#status.EnPanne{
color: white;
text-align: left;
font-size:17px;
font-weight:700;
letter-spacing:1px;
background: url(images/red.jpg) no-repeat;
}
And have the text display on the red bar be En panne instead of EnPanne?
Basically I'm trying to add a custom text attribute to the EnPanne property so that it displays what I want it to while still using the right property.
Edit:
With the solution posted by jme, I was able to produce these results.
Below is an example of what the English "Down" status will display, above is what I need to do for French display. It appears that the follow-up text is cutting off the "redbar.jpg" and preventing the bar from extending to the other end of the page.
I would assume my two options here are somehow force the redbar over the following text or somehow remove that following text so the bar can fully stretch to the end of the page?
Edit 2:
Here is the portion of the script that connects the XML with the html and CSS - specifically for the system status:
<script> <!--Loads the Status_Pages.xml file-->
var root = null;
$(document).ready(function ()
{
$.get("Status_Page.xml",
function (xml)
{
...
var status=$(root).find("systemStatus").text();
$("td#status").html(status);
$("td#status").attr("class", status);
...
});
});
</script>
How I would do this is to simply set the class attribute and allow your css to add the content, versus adding the status text into the table cell in your ajax call. So, to do this you would remove this line: $("td#status").html(status);
Then in your css you could do this:
#status{
color: white;
text-align: left;
font-size:17px;
font-weight:700;
letter-spacing:1px;
}
#status.Normal{
background: url(images/greenbar.jpg) no-repeat;
}
#status.EnPanne, #status.Down {
background: url(images/red.jpg) no-repeat;
}
/*Now set your messages*/
#status.EnPanne:before {
content: "Le système est en panne";
}
#status.Normal:before {
content: "Operations Normal";
}
#status.Down:before {
content: "The system is currently down";
}
Here's a fiddle demo.
If you're against the idea of not adding the text into the table cell, here is an example that uses a technique to hide the table cell text while absolutely positioning the content: demo 2. If you want an explanation of this method, let me know.
What about escaping a space?
#status.En\ Panne {...}
And in your XML normally
<systemStatus>En Panne</systemStatus>
Related
I have an app for the 2018 World Cup calendar and I want to update it to 2022. I ran into a couple of problems:
The form in the title used to show a background image and now I can't get it to appear. I have tried with tbMenu.getTitleComponent().setUIID("TitleArea"); and it does not work.
TitleArea {
background-image: url(images/rojo.png);
background-color: red;
color: white;
text-align: center;
font-family: "native:MainBold";
font-size: 3.5mm;
}
I also put buttons that change when pressing a forward or back command and now it only shows the first time and when I press the command the area appears blank.
Try "tbMenu.setTitleComponent(cnP);" which works for the first time but it doesn't update when i press the command.
I appreciate the support
Hi,
I have placed an image in drive because stackoverflow sends me an error when trying to place it. https://drive.google.com/drive/folders/1LVBZPMCTTTEZxEYfwrh3S2_fPzyktTiN
As you can see, I tried several combinations and not from what I deduced the problem is about the title area because in certain parts it works. I copy the changes I made to the CSS and the image shows the result in the hope that it will tell me which is the correct way.
Title {
background-image: url(images/titulo.png);
cn1-background-type: cn1-image-scaled-fill;
color: red;
text-align: center;
font-family: "native:MainBold";
font-size: 3.5mm;
}
TitleArea {
background-image: url(images/titulo.png);
cn1-background-type: cn1-image-scaled-fill;
color: black;
text-align: center;
font-family: "native:MainBold";
font-size: 10mm;
}
TitleCommand {
background-image: url(images/titulo.png);
cn1-background-type: cn1-image-scaled-fill;
color: black;
text-align: center;
font-family: "native:MainBold";
font-size: 10mm;
}
TitleCustom {
background-color: transparent;
color: white;
text-align: center;
font-family: "native:MainBold";
font-size: 3.5mm;
}
I also include the method where I load the titles for the first time.
final Toolbar tbMenu = new Toolbar();
this.setToolBar(tbMenu);
Vector vGP = grupoResultadosActivos("A");
Container cnP = new Container(new BoxLayout(BoxLayout.Y_AXIS));
Label lbTitulo = new Label("GRUPO A");
lbTitulo.setUIID("Title");
cnP.addComponent(lbTitulo);
if (vGP.size() > 0) {
int cnt = contadorBarraPaises(vGP);
if (cnt > 0) {
cnP.addComponent(cargaBarraPaises(vGP, cnt));
}
}
cnTitleArea.add(cnP);
cnTitleArea.setUIID("TitleCustom");
tbMenu.setTitleComponent(cnTitleArea);
tbMenu.repaint();
It's hard to tell with things like this. I suggest using the component inspector and reviewing the components in the hierarchy to see what went through then editing the CSS dynamically to see the changes.
Important: sometimes changes don't apply in this way!
You will need to stop the simulator and delete the res file. Then do a clean build. It's rare but it happens in some configurations and might be misleading.
About the specific issues. For the first try adding:
cn1-background-type: cn1-image-scaled-fill;
setTitleComponent is problematic since it overrides the entire title area. Many generic behaviors will stop working if you do that. It's an all or nothing situation and might be the reason other things don't work.
I am using a donation widget from another company which I have made use of on my website. I would like to change the size of the photos in the dropdown menu next to the item on the menu. I want to change it to 50x50 pixels.
Unfortunately, all I have is the widget code itself. I do have a image example, that could help to clear up what I'm talking about.
$data.WebPhotoId {
max-width: 50px;
max-height: 50px:
}
dropdown-menu databind= {
max-width:50px;
max-height:50px;
body {
font-size: 16px;
font-family:Helvetica, Arial, sans-serif !important;
color: #676767;
}
}
My question is, is there any way I modify my CSS in order to change the menu item pictures?
Well if it is set with <img src="path/to/image"> you can't do it nicely with CSS.
In that case I would suggest using JavaScript or jQuery for this.
var image = document.getElementsByClassName('image-class')
for(var i = 0; i < image.length; i++) {
image[i].src="path/to/new/image";
}
With CSS you can set background-image: url('path/to/new/image') but I don't think it will work in case where image is set with <img src="path/to/image">
I am setting a string for a chapter title using string-set.
When I add content and re-use that string through my document, I would like it to maintain the original formatting of my h1 (font-weight:bold).
How can I do that? I cannot just style the content because the rest of the content("My Document Title") should not be bold.
At the moment, I am using the string as part of a header:
h1{
font-weight:bold;
string-set:chaptitle1 self;
}
#page chap1 {
#top-left {
content: "My Document Title" string(chaptitle1) ;
}
}
Maybe I don't fully understand your question but you should be able to define properties to #top-left region.
example:
#page chap1 {
#top-left {
content: "My Document Title" string(chaptitle1) ;
background-color: #ff0000;
color: white;
}
}
This would show the background of the text red and the text white. This absolutely works in PrinceXML.
I am building a webapp in .net using some of the AJAX features; in this case it is TabContainer.
Below is a screenshot of the area I want to play with.
The menu on the left is the tabs of TabContainer. The right side is tab's content. I would like to have the "Update PCR" button to be right underneath "Disciplines Affected". The problem is that the left and right side are a part of ONE block, which is TabContainer.
Are there any suggestions to how would I format the CSS of the Button to align right underneath TabContainer's menu? I could add the button as a part of the menu but, then I would have to set the control to AutoPostback, which defeats its purpose in this case in the first place... Any suggestions would be appreciated!
EDIT:
Here is the existing CSS
.ajax_tabController .ajax__tab_tab
{
background-color: #3c6f91;
padding: 5px;
border: 1px solid #ffffff;
color:#ffffff;
border-left: 3px solid #5AB0DB;
}
.ajax_tabController .ajax__tab_hover .ajax__tab_tab
{
background-color:#5AB0DB;
text-decoration:none;
}
.ajax_tabController .ajax__tab_active .ajax__tab_tab
{
background-color:#5AB0DB;
text-decoration: underline;
}
Also, there is CSS that overrides some settings to make TabContainer Vertical instead of Horizontal. I know, that there is a property .UseVerticalStripPlacement but it messes up with the height of the control and throws a JavaScript error.
.ajax__tab_header
{
float: left;
}
.ajax__tab_body
{
margin-left: 160px;
}
.ajax__tab_outer
{
display: block !important;
}
.ajax__tab_tab
{
width: 210px;
height: auto !important;
}
You need to position the top of the button relative to the bottom of the tab elements. This can be done with jquery. See How to position one element relative to another with jQuery?
It's going to be a bit hit and miss, but try something along the lines of:
.updatePcrButton {
position: absolute;
top: 100px; /* These will be whatever the measurement is to */
left: 5px; /* be directly under the last element */
z-index: 99; /* Arbitrary amount to put it above any other elements */
}
This is pretty messy to be honest - it relies on your not changing the position of the control thereafter.
Perhaps a better way would be to add an extra tab to the TabContainer and handle any Tab clicks yourself.
-- Edit -- May be more useful --
Nikita, I had completely forgotten about this as it was in an old Classic ASP app of mine, but you could try these two JS functions that are probably more useful to you:
function curTop(obj){
rv = 0;
while(obj) {
rv += obj.offsetTop;
obj = obj.offsetParent;
}
return rv;
}
function curLeft(obj){
rv = 0;
while(obj) {
rv += obj.offsetLeft;
obj = obj.offsetParent;
}
return rv;
}
They pull the position from the specified object. If you add the height of the button that you want to position under then you may find this improves the location for you and prevents any funny business with CSS.
Kind regards,
Westie.
My excuses in advance, since this seems to be a problem concerning very basic understanding of CSS and maybe also Javascript.
What I want to do is this: imagine a div which contains a h3 and a p. On hovering on the div I would like the h3 and p to change their font-weight. So far I am using this code here to change the opacity and border on hovering over the div, but I really don't know how I can refer to the two elements inside the div. I'm really sorry, but I need someone to explain it to me in very simple terms.
For example, I think those elements inside the div are called children, but I'm not even sure about that... I'm really working with all that HTML/CSS/Java stuff for the first time and try to figure things out as I go along. The tutorial sites I found so far couldn't solve my problem, therefore this post.
More background information: I'm using the "smoothgallery" script by jondesign (Jonathan Schemoul) () and am trying to bend it to my will, but that is pretty difficult if you don't have any clue how it actually works. The site I implemented the script in can be found here.
Here comes the CSS part that changes the div on hover:
.jdGallery .gallerySelector .gallerySelectorInner div.hover{
border: 1px solid #89203B;
border-left: 0.8em solid #89203B;
background: url('../../images/teaserBox_bg.jpg') no-repeat;
background-size: 100% 100%;
filter:alpha(opacity=1);
-moz-opacity:1; /
-khtml-opacity: 1;
opacity: 1;
}
This entry in the CSS file changes the settings for e.g. the h3 inside that div,
.jdGallery .gallerySelector .gallerySelectorInner div.galleryButton h3{
margin: 0;
padding: 0;
font-size: 12px;
font-weight: normal;
}
You may also want to take a look at the .js file that makes these classes, it can be found here.
This is probably the most important part here:
createGalleryButtons: function () {
var galleryButtonWidth =
((this.galleryElement.offsetWidth - 30) / 2) - 14;
this.gallerySet.each(function(galleryItem, index){
var button = new Element('div').addClass('galleryButton').injectInside(
this.gallerySelectorInner
).addEvents({
'mouseover': function(myself){
myself.button.addClass('hover');
}.pass(galleryItem, this),
'mouseout': function(myself){
myself.button.removeClass('hover');
}.pass(galleryItem, this),
'click': function(myself, number){
this.changeGallery.pass(number,this)();
}.pass([galleryItem, index], this)
}).setStyle('width', galleryButtonWidth);
galleryItem.button = button;
var thumbnail = "";
if (this.options.showCarousel)
thumbnail = galleryItem.elements[0].thumbnail;
else
thumbnail = galleryItem.elements[0].image;
new Element('div').addClass('preview').setStyle(
'backgroundImage',
"url('" + thumbnail + "')"
).injectInside(button);
new Element('h3').set('html', galleryItem.title).injectInside(button);
new Element('p').addClass('info').set('html', formatString(this.options.textGalleryInfo, galleryItem.elements.length)).injectInside(button);
}, this);
new Element('br').injectInside(this.gallerySelectorInner).setStyle('clear','both');
},
So my question here is, if it is possible at all to change the h3 and p settings by using the hover function on the main div?
Thanks in advance! Also for negative criticism, I don't really know if I did something wrong in the way I posted this question and if I can even ask it here.
You're making this way more complicated than it needs to be. No Javascript is required to do this. Let's say you've got the following:
<div class="container">
<h3>This is a header</h3>
<p>This is a paragraph</p>
</div>
So you've got a container, with a header and paragraph. Let's say you want to have the header normal weight, and the paragraph in red normally, with a padded box around the whole thing. Here are your styles:
.container { border: 1px solid black; padding: 10px; }
.container h3 { font-weight: normal; }
.container p { color: red; }
When you hover the mouse over the , you want the paragraph and header in bold and the box border to change to blue. Add this into your stylesheet (or <style> block) below the CSS above:
.container:hover { border-color: blue; }
.container:hover h3 { font-weight: bold; }
.container:hover p { font-weight: bold; }
Note that you can save a bit of space, and make it more concise by combining the <h3> and <p> styles into one line with a comma, since they're both the same. The whole thing would now look like this:
.container { border: 1px solid black; padding: 10px; }
.container h3 { font-weight: normal; }
.container p { color: red; }
.container:hover { border-color: blue; }
.container:hover h3, .container:hover p { font-weight: bold; }
Remember that the "C" in "CSS" stands for "cascading": styles cascade down through both hierarchies (that is, a parent element's style also applies to a child element, unless it's got default styles like margins or whatever), and down the style sheet - that means styles you define after others will override them if they apply to the same element.
The ":hover" selector in CSS can pretty much be used on anything, with very few exceptions. I use them regularly for Javascript-free drop-down menus. You can find more on the ":hover" CSS selector here: W3Schools CSS reference on ":hover". In fact, the W3Schools site is a generally great resource for brushing up your CSS.
because short answers what we always prefer to look for:
.classname :hover *