I have a <p:menubar> in a xhtml template. The div that surrounds it has these CSS properties:
position: fixed;
top: 44px;
width: 100%;
So I can fix the menu header while user scrolls down the page.
The problem now is that some Prime Faces component have icons and headers overflowing the menu.
I tried to work with z-index but no success. I imagine that there is another solution in PrimeFaces instead of z-index.
Thanks a lot.
According to the PrimeFaces default style sheet primefaces.css, the <p:message(s)> icon is relatively positioned.
.ui-messages-info-icon, .ui-messages-warn-icon, .ui-messages-error-icon, .ui-messages-fatal-icon, .ui-message-info-icon, .ui-message-warn-icon, .ui-message-error-icon, .ui-message-fatal-icon {
background: url("/omnifaces/javax.faces.resource/messages/messages.png.xhtml?ln=primefaces") no-repeat;
display: block;
float: left;
margin: 0;
padding: 0;
position: relative;
}
I'm in first place not sure why it's relatively positioned as it doesn't seem to need to be offsetted nor have any absolutely positioned children. Perhaps it's been used as some (most likely IE-specific) workaround/hack for something else (if this was "has layout" related, the developer would better have used overflow: hidden instead for this). So just making it the default position: static should fix it.
Add the following to your override stylesheet to achieve this:
.ui-messages-info-icon, .ui-messages-warn-icon, .ui-messages-error-icon, .ui-messages-fatal-icon, .ui-message-info-icon, .ui-message-warn-icon, .ui-message-error-icon, .ui-message-fatal-icon {
position: static;
}
Alternatively, you could of course also set z-index of the menu with an insane high value, as you figured out yourself. I wouldn't consider this a reliable solution though, this is too much a workaround/hack.
Resolved it by setting the z-index: 9999999 to the <p:outputPanel> sorrounding the menu instead of setting the style property in the menu.
Related
I'm finding a behavior that's really strange (at least, on the CSS side) in the CellTable component of GWT.
Suppose we examine the following CellTable demo: http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwCellTable
If I try to add ellipsis to the header (TH tags) only by using CSS, by the following code (we can try to add this in the clean.css file directly in the Developer tools of browser):
th {
text-overflow: ellipsis;
overflow: hidden;
width: 50px;
display: inline-block;
white-space: nowrap;
}
This works with a normal HTML test page (according to this question), but not in this case: the headers will break into newlines instead.
I can't figure out which CSS properties of the elements have interfered with this simple approach.
Sorry for the simple question, but I'm learning CSS and try to experiment more with it, thus thanks in advance for any support.
Otherwise, I can try to solve this on the Java side, and custom the header with a builder.
I'm trying to make the second menu sticky below the first menu. The first menu has been made sticky by default (Theme setting).
As the height of the first menu varies for mobile/desktop, I can't set top: 120px or something.
I did try position:sticky and got it to work reasonibly well, however the issues start when testing it on mobile.
So; is there a possibility to make the second menu sticky below the first one?
https://www.salonivon.nl/custom-webshop-tryout/
Thanks in advance,
Richard
The code I used was:
`.my-extra-WooWidget{
position: sticky;
top: 104px;
z-index: 100;
background:white;
width:100%;
padding-bottom:10px;
}
`
This works as long as I'm on the desktop screen.
I'm not able to change the header tho
I would suggest using a fixed position and setting the CSS for top: top: 105px, then using media queries set a different value for mobile screen sizes. Here's a code sample:
widget.my-extra-WooWidget {
top: 105px; /*Use a suitable value here*/
left: 0;
right: 0;
background-color: #fff;
position: fixed;
z-index: 1;
}
#media (max-width: 768px) /*Use a suitable screen size here*/ {
top: 76px; /*Use a suitable value here*/
}
I'm styling my GWT CellTable cells by overriding getCellStyleNames in my column definition. Styles are working, on the most part. I'm trying to color the background of a 4-pixel wide column, with mixed display results depending on the browser engine. I'm expecting the following to work, but it doesn't. I need to set the height for firefox to 0, otherwise the first row appears to have a larger height than the rest of the rows. Any ideas?
.wt-tableRowGreen {
background-color: #8DAF00;
width: 0px;
padding-left: 4px !important;
padding-right: 0px !important;
display: compact;
height: 100%;
}
Setting height to 0 works fine for FF, but breaks the others. Using browser specific selectors isn't working:
-ms-height: 100%;
-webkit-height: 100%;
-moz-height: 0;
If you want to target spesific css for Firefox, this is the solution I use:
#-moz-document url-prefix()
{
/* Css for FF here */
}
Obviously, this is something one should generally avoid, but in some cases it's virtually impossible to get around it.
Can we get the value from inside a css definition in the code if CSS resource is used?
e.g.
.iv_menu_thumbnail {
display: block;
width: 24px;
height: 24px;
margin: 3px;
float: left;
cursor: pointer;
}`
Can we know via code the value of width and i want to access from one of my java class?
Thanks in advance
var width = $('.iv_menu_thumbnail').width();
console.log(width);
This will get the width of the element if this is what youre asking for.
As far as I'm concerned you cannot get non numerical values from a css declaration.
But you can set your own values via jQuery using the
.css()
So it would look like this if you want to set a new css value. (or overwrite it)
$(someelement).css('float', 'left');
As far as I know, you can only inspect the computed CSS property on an element where this has been applied. Like:
$(someElementOrId).css('width');
or
$(someElementOrId).width();
Note that the former and the latter differ - the former does not contain the unit of measure, the latter does.
You can have a variables in your Css Resource file and set the width attribute with that variable, and then access the width varialbe from code.
CssResource
Css Resource file
#def small 1px;
#def black #000;
border: small solid black;
Java Code
interface MyResources extends CssResource {
int small();
}
There are a few ways out there in the internet to centre something on the screen via css (-ve margins, table-cell hack etc). I was quite happy with that until now when I wanted to use native gwt2.0 layout panels/widgets. Imagine you want to do a "loading screen" to show a spinning circle until the app tries to figure out where to send user next (in background the app is checking if user is logged in or not).
I have this code in gwt uiBinder xml:
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field='res' type='ru.atamur.resources.CommonBundle'/>
<g:HTMLPanel>
<g:Image resource='{res.loader}'/>
</g:HTMLPanel>
</ui:UiBinder>
I basically want the image to be displayed in the center of the screen both vertically and horizontally.
Any bright ideas how to achieve that w/o scripting getWidth/setHeight etc?
Thanks.
In the end I was able to use general css with the help of HTMLPanel:
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<ui:with field='res' type='ru.atamur.resources.CommonBundle'/>
<g:HTMLPanel>
<div class="{res.centerStyle.container}">
<p class="{res.centerStyle.centered}">
<g:Image resource='{res.loader}'/>
</p>
</div>
</g:HTMLPanel>
</ui:UiBinder>
where corresponding css (linked via a bundle) is:
.container {
top: 0;
left: 0;
width: 100%;
height: 100%;
position: absolute;
display: table
}
.centered {
display: table-cell;
vertical-align: middle;
text-align: center;
}
the only hint here was to call ensureInjected in the corresponding widget constructor (see http://code.google.com/p/google-web-toolkit/issues/detail?id=4408 for details):
#UiField CommonBundle res;
public LoadingScreen() {
initWidget(uiBinder.createAndBindUi(this));
res.centerStyle().ensureInjected();
}
I'm not sure why you're against scripting to achieve this, especially since you're going to need at least some amount of scripting in order to show and hide the loader at the right times. You may find your solution isn't going to work well across browsers.
GWT has the PopupPanel, which makes what you're trying to do quite simple.
// A popup that doesn't auto-hide, and doesn't let the
// user click on anything else.
PopupPanel popup = new PopupPanel(false,true);
popup.setGlassEnabled(); // Dims the rest of the page
popup.setWidget(new Image(res.loader()));
popup.center(); // Show popup centered
Then you just call popup.hide() when you're done.
Centering items can also be done using UIBinder without CSS:
<g:HorizontalPanel width="100%" height="100%">
<g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
<g:Label>Hello Center</g:Label>
</g:cell>
</g:HorizontalPanel>