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*/
}
Related
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.
Is it possible to share variables between Less(CSS) and CoffeScript(JavaScript) in Play.
Less:
#width: 600px;
#height: 800px;
.right {
width: #width;
height: #height;
}
CoffeScript:
width = 600
height = 800
stage = new Kinetic.Stage(
container: 'mainCanvas'
width: width
height: height
)
I find it highly inconvenient to have to repeat myself in both files.
Naturally I would like to be able to define the width and the height at a higher abstraction layer.
Of course any technique that is more general and may be applied to any framework is also appreciated.
There is no way as far as I'm concerned.
Maybe you can define a class in CSS and adjust the width and height just from style.
What if you simply try to set the css-class via jquery?
stage = new Kinetic.Stage
container: 'mainCanvas'
width: 0
height: 0
mc = $("#mainCanvas")
#assuming that mainCanvas is the element you want to style
mc.addClass "right"
Rosetta is what you are looking for.
From npm page...
Example
Imagine you want to want to create a shared variable:
$thumbnailSize = 250px
Rosetta allows you to use this variable in both your Javascript:
var rosetta = require('./rosetta');
console.log('Thumbnail size is:', rosetta.thumbnailSize.val);
...and your CSS (in this case, a Stylus file):
#import rosetta
.thumb {
width: $thumbnailSize
height: $thumbnailSize
}
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.
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>