I have several combo boxes all over the page. And there is one combo box that I want to be responsive.
Let's assume I have layout containing it, just like this:
public class MyLayout extends CssLayout ... {
...
void initLayout {
displayBoxFilter = new ComboBox();
displayBoxFilter.addStyleName("displayBoxFilter");
}
}
and I have CSS like this:
.MyUI {
...
.displayBoxFilter {
color: red;
}
}
.MyUI[width-range~="0-767px"] {
...
.displayBoxFilter {
color: blue;
}
}
But when I do this, only combo-box-caption colors get changed. But I also want to change the color of the popup window.
According to combo box CSS style rules (https://vaadin.com/docs/-/part/framework/components/components-combobox.html) i add v-filterselect-suggestpopup and nested styles outside MyUI style:
.v-filterselect-suggestpopup {
.gwt-MenuItem {
color: yellow;
}
}
.v-filterselect-suggestpopup[width-range~="0-767px"] {
.gwt-MenuItem {
color: green;
}
}
After that, i have a combo box with caption colors that responsively get changed. But popup window color remains same (always yellow).
I think it's because popup window is rendered outside my responsive UI. Responsive.makeResponsive(displayBoxFilter) didn't work. How do I make this window responsive?
Any suggestions would be helpful!
Thanks in advance
UPD based on Jouni's answer (worked for me):
I have added #media outside #mixin in mytheme.scss like this:
#mixin mytheme {
#include theme;
...
}
#media (max-width:767px) {
.mytheme {
.gwt-MenuItem {
color: green;
}
}
}
This is a limitation in the Responsive extension, that it doesn’t apply to any overlay elements (except the Window component).
You’re best workaround is to use regular CSS media queries.
Related
I have a <mat-tree> component where styling for dependant <mat-tree-node>'s introduces a special background color for mouse hovering:
mat-tree-node {
// ...
&:hover {
background: $hoverColor;
}
}
In the tree, some elements may be selected by the user. In order to highlight them visually, a special class is applied to <mat-tree-node> as [class.highlight]="isHighlighted(node)" and the class is defined as follows:
highlight {
background-color: $selectColor;
}
My problem arises when a node is selected and hovered at the same time. I want the selectedColor to take priority but the node gets hoverColor background when hovered. I changed the definition to this:
mat-tree-node.highlight {
background-color: $selectColor;
&:hover {
background-color: $selectColor;
}
}
Google Chrome developer console started to show the class higher in the stack as now it has +1 point of selectivity, but when hovering, the hoverColor is still being applied to the background, and even !important does not help.
Why does not it obey the new definition and how to fix it?
Try this:
mat-tree-node.highlight {
background-color: $selectColor;
}
may-tree-node:not(.highlight):hover {
background-color: $hoverColor;
}
Anyone have idea how can I hide text, date or something on page, but when I click button for window.print() show it there?
I'm using:
#media print {
#page { margin: 0; }
body { margin: 1.6cm; }
}
#media print {
.hide-from-printer{ display:none; }
}
Print
So like this button class="hide-from-printer", it shows on page but hide from printing page. I want to do vice versa (on the contrary). Any suggestion?
Use this way:
.hide-from-page { display:none; } /* hide at normal page view */
#media print {
.hide-from-page { display:inline; } /* make it visible during print */
}
Note: its obvious to rename the class to mean correctly (instead of hide-from-printer, it must be something like as hide-from-page or show-only-at-print)
you can use ´screen´ for regular screens so all you would have to do is
#media screen {
.hide-from-screen {
display: none;
}
}
#media print {
.hide-from-printer {
display: none;
}
}
and use those classes accordingly.
This is my class:
.center-block-xs {
// This style is given to an image. I want the image to keep
// its original CSS (whatever the default display and margin
// is for an image) unless the screen size fits within the
// media query below.
}
#media(max-width:767px) {
.center-block-xs {
display: block;
margin-right: auto;
margin-left: auto;
}
}
Basically, what I want to do is this: If an element has the class .center-block-xs, then the CSS should be applied to the element only if the screen size is within the media query. I know I can do this:
#media(max-width:767px) {
.color-red-xs { color: red; }
}
#media(min-width:768px){
.color-red-xs { color: black; }
}
In which case the color is red only if the screen size is within the media query, otherwise it gets overridden with the black color. But I don't want to have to override any CSS in my case; I just want the CSS to be what it normally would be unless the screen size is within the media query. Is this possible?
What you're describing is precisely how CSS and media queries work by default. If you define a class of .center-block-xs within a media query, that definition will only be applied to elements that a) have that class, when b) the media-query rules apply. There is no need to explicitly define the alternative case(s) if you want inherited styles to be applied.
Just set the default color to what you want, such as the following:
.center-block-xs {
color: red;
}
Then set a minimum width for the CSS change, like so:
#media(min-width: 767px) {
.center-block-xs {
color: black;
}
}
when the screen hits a width of 767px, the text will change.
I came across this strange phenomena while toying on codepen.
I set my various font sizes as vw values, but it created some strange behavior:
The font size will only display correctly while my elements are on hovered state, and will render as 0px if they are not.
Here's my SCSS :
$title:2vw;
$subtitle:1.5vw;
$text:1vw;
and
p {
color:$red;
font-size:$text;
}
h1 {
color:$black;
font-size:$title;
}
h2 {
color: lighten($black, 20%);
font-size:$subtitle;
}
Those elements have no set class in my html, except being children of divs which are styled as such:
#mixin div {
border:$border;
border-radius:$border-radius;
background-color:$green;
color:$black;
padding:$padding;
margin:$margin;
&:hover {
background-color:$black;
color:$green;
h1 {
color:$green;
}
p {
color:$green;
}
}
}
And here is the link to the pen page: http://codepen.io/rlacorne/pen/tgrbn
Anyone knows what's happening? It's bugging me.
Thanks in advance!
I have installed Wordpress 3.6.1, and theGrid Retina Ready One-Page Wordpress Theme.
I have created two CSS classes "redback" and "greenback" in my theme, within Wordpress Dashboard, for my top-menu, in order to place on the right respectively the "ESPAÑOL" and "FRANÇAIS" buttons, as you can see on the website: Website
I have settled all the mediaqueries files in order to adapt the website menu to the different sizes of the screens. And it works, except for the screen below width of 767px (on mobile phones).
The two words "ESPAÑOL" and "FRANÇAIS" don't line-up vertically with the other.
I have tried many solutions, but nothing works.
If I change the CSS classes "redback" and "greenback" to adapt it to the screen, then they don't match with the screen above width of 767px.
And if I put the CSS classes in my media-queries file in each category size of screen, nothing seems to work.
Have you any recommendations for it?
I thank you in advance, any help is appreciated.
I played with this in chromes dev tools and I think if you "reset" your two classes things will line up perfectly. So for example you could do:
.redback, .greenback {
padding: inherit
margin: inherit
etc.
}
Kinda dirty though.
You could also just javascript the classes away at that screen size and just let them inherit the properties with the rest of the li's.
I am not a JS/jQuery expert by any means. In fact I know very little but based on this post I put this together in a CodePen.
You just need to plug in your id's and class names where appropriate.
HTML
<p id="foo" class="blue">Color</p>
CSS
p {
font-size: 3em;
font-weight: bold;
text-transform: uppercase;
text-align: center;
}
.blue {
color: blue;
}
.red {
color: red;
}
jQuery
$(window).resize(function(){
var width = $(window).width();
if(width < 767) {
$('#foo').removeClass('blue').addClass('red');
}
else {
$('#foo').removeClass('red').addClass('blue');
}
}).resize();
Ok, I have tried the first method, but indeed, it's a little dirty. I want to try the second method, from javascript, but I am totally new to this. However, I have found the following code where I can change my CSS classes:
jQuery(document).ready(function(){
jQuery('#nav-button').click(function() {
jQuery('#options li').toggle();
});
if ( jQuery(window).width() < 767) {
jQuery('#options li a').click(function() {
jQuery('#options li').hide();
});
}
jQuery(window).resize(function() {
if ( jQuery(window).width() < 767) {
jQuery('#options li a').click(function() {
jQuery('#options li').hide();
});
}
});
jQuery(window).resize(function() {
if ( jQuery(window).width() > 767) {
jQuery('#options li').show();
jQuery('#options li a').click(function() {
jQuery('#options li').show();
});
}
});
});
But I don't know how to change it in order to apply what you have tell me before. (I only want to cut all the padding from the css classes "redback" and "greenback" off for the width < 767).