I use angular material for ui component and follow the below tutorials to create my own page.
https://stackblitz.com/angular/pbndqaomepr?file=app%2Fmenu-overview-example.html
When I click menu, angular shows a div containing Item 1 and Item 2 that's ok fro big screen. What I tried to do is to be sure that the div expands to the full browser windows just in case mobile devices.
So I added the following css:
#media only screen and (max-width: 600px) {
.menu-screen {
position: fixed;
width: 100vw;
height: 100vh
}
}
And use the following menu template:
<button mat-button [matMenuTriggerFor]="menu">Menu</button>
<mat-menu #menu="matMenu" class="menu-screen">
<button mat-menu-item>Item 1</button>
<button mat-menu-item>Item 2</button>
</mat-menu>
And nothing happens.
I need that matMenu item to cover the full monile screen.
What I'm doing wrong ? One of my friends suggested listening menu item opened event and to show a pop-up filling the window. However, I felt that it would be cumbersome.
Thanks
First of all, you either need to apply that css code for the whole document, or if you keep the css in your component, you need to set the encapsulation mode of the component to NONE.
Because the menu is created in an overlay container as a child to your body element, not as a child to your component.
Secondly, angular material creates several containers with which encapsulate the menu, and their positions need to be overridden.
So, in your menu-overview-example.css file, put this code:
.cdk-overlay-connected-position-bounding-box {
left: 0 !important;
}
#media only screen and (max-width: 600px) {
.menu-screen {
position: fixed;
max-width: unset !important;
width: 100vw;
}
}
and in your menu-overview-example.ts file, add this to your component decorator:
#Component({
...
encapsulation: ViewEncapsulation.None
})
I've created a forked working version of your code here:
https://stackblitz.com/edit/angular-sjy3em
You probably want to make the selectors more specific so you can remove the !important directive from your code, it's bad practice but I used it for simplicity here.
Related
I wrote a little program in angular using an ui-select element. The problem is that the search bar is really too long and I didn't find how to reduce it. Usually, we have some "width" properties that you can change for that but the css code is too complicated and I didn't find how to manage that. What I want to do is to save three bars at the same line.
I copied the sample from the official page of the ui-select, so it contains a lot of things in css that I didn't understand and I don't know much about css or bootstrap...
The style element in the index.html is this one :
<style>
body {
padding: 15px;
}
.select2 > .select2-choice.ui-select-match {
/* Because of the inclusion of Bootstrap */
height: 29px;
}
.selectize-control > .selectize-dropdown {
top: 36px;
}
</style>
</head>
And they included a huge select.css file in their sample that you can find in my plunker : http://plnkr.co/edit/kuryoI5osBtRihYAeoVH?p=preview
Can you show me how can I reduce the width of th search bar?
Can you PLEASE show me how to remove all the unecessary line from the select.css included in the plunker that are not used in my example ?? I don't know how can I do that efficiently. I'm afraid to delete important elements and I really got lost in that huge css file.
Thank you in advance !
Edited 2 (How to use the col-xx-nn) properties with bootstrap
The xx indicates in which view you want the property to be applied:
xs : extra-small devices
sm: small devices
md: medium devices
lg: lg devices
The nn indicates how many column the element will occupy (total is 12). Please see http://getbootstrap.com/getting-started/ for reading the full docuemntation.
And this is how your code would be...
<div class="row">
<!--First ui-select-->
<div class="col-md-4"> <!--1/3 of 12 -->
<ui-select ng-model="selectedItem">
<!--ui-content-here--->
</ui-select>
</div>
<!--Second ui-select-->
<div class="col-md-4"> <!--1/3 of 12 -->
<ui-select ng-model="selectedItem">
<!--ui-content-here--->
</ui-select>
</div>
<!--Third ui-select-->
<div class="col-md-4"> <!--1/3 of 12 -->
<ui-select ng-model="selectedItem">
<!--ui-content-here--->
</ui-select>
</div>
</div>
Edited
Include a custom css and put these rules. Make sure to include this after the ui-select css files in order to overwrite its rules:
.ui-select-container {
max-width: 200px; /*put the desired width here!*/
}
.ui-select-bootstrap > .ui-select-match > .btn {
max-width: 200px; /*put the desired width here!*/
}
.ui-select-bootstrap > .ui-select-choices {
max-width: 200px; /*put the desired width here!*/
overflow-x: scroll;
}
.ui-select-container .form-control {
max-width: 200px; /*put the desired width here!*/
}
Check this working plunker http://plnkr.co/edit/GN8i5PeFebS7Bo04GiUt?p=preview
In this plunker the rules are in myOwnCss.css file and I needed to add another custom rule in order to get this done properly because some of the other default styling of the ui-select. See below
/**some additional styling in order to get
the demonstration working properly (very possibly not needed for you)*/
.ui-select-bootstrap .ui-select-choices-row.active > a {
color: black;
background-color: white;
}
Important!:
Please, be aware that if you have an option with a name too long (it
takes more than you desired width, 200px in this case) it won't be
show completely in the selected option, and besides you have to
scroll over the x axis in order to read it completely in the dropdown
list.
When you create a ui-select item, it will generate a div for all its content, and with three bars, all those divs will probably be shown, one below the others. (TIP: you can solve this using bootstrap classes: col-md-4 for every div which wraps every ui-select)
I have a normal, general CSS for a website.
After creating some #media queries to make my elements have different colors, sizes and etc on mobile and different resolutions, everything is fine.
The problem is when I resize the windows from a normal size to a small one, the effects are applied, but when I resize back to the normal one, the css is not refreshed, some "mobile" rules stay there.
How can I re-render the css without the #media rules, not refreshing the page.
This is an example of my HTML:
<div class="item">
<span class="item-foo">FOO </span>
<span class="item-bar">BAR </span>
</div>
With the following css:
.item-bar{
float: right;
}
#media only screen and (max-width: 992px){
.item-foo, .item-bar{
display: block;
float: none !important;
}
}
Here is a codepen of it:
Codepen
If you resize the view area to a small size until they turn in one span each line and go back to a bigger size, the "bar" element won't be in the right place.
As #JesseKernaghan pointed out in the comments, this is a chrome bug.
The easy-fix would be increasing the specificity for the button fixes this, as suggested by #SeanKeating.
In this question's case, adding this style fixed the problem:
.item .item-bar{
float: right;
display: inline;
}
Here is the codepen updated with the easy-fix
http://codepen.io/matheusbaumgart/pen/yyzXpp
i have a problem with z-index on my webpage, i need move shopping bottons to the top -100px but when i try it the button loose the actions not work anymore, i try to use z-index: 99999 but not work too, i need some help! here my page link limitx.panamerik.net
----IMAGES-----
This is the real image:
I need make this:
You're using top value in negative that means there could be problems with the followings:
the parent div is set to overflow:hidden; and don't show the element i.e. hide the element going behind the parent div. (remove overflow:hidden from the parent)
z-index value is not working? You didn't explicitly declared the position. (set position:relative or absolute)
UPDATE: After looking at your screen shots again I realized that you want to display the button to the right of the product images. I'm not sure if this is a good idea, because this theme is meant to be responsive.
But if you really, really, really want to do this then you may try to add the following <CSS> to your custom.css file:
#media only screen and (min-width: 768px) {
.products-grid .actions {
margin: 0;
position: absolute;
top: 100px;
right: -25px;
}
.owl-wrapper {
z-index: 1;
}
.slider-arrows1 .owl-controls .owl-buttons .owl-prev, .slider-arrows1 .owl-controls .owl-buttons .owl-next {
z-index: 2;
}
}
This will work as you can see in the screen shot below, when hovering the button.
I have added #media only screen and (min-width: 768px) because of the responsive nature of the theme. Otherwise, when the browser viewport gets smaller, the buttons would overlap the image. You may want to play a little with this setting and should test it on some mobile devices too.
To learn more about this see this question.
EDIT: I'll leave my original answer below, just in case this may
helpful to someone else in the future...
I see that you use Infortis Ultimo theme, which is a great choice. I don't think you should use <CSS> to move the button. It is better to move the entire <div class="actions"></div> to the top.
The result will look like this:
You can do this by making some changes to the following file:
app/design/frontend/ultimo/default/template/catalog/product/list.phtml
Somewhere around lines 273 to 289 (depending on the themes version) you will find the code for this:
<div class="actions clearer<?php echo $actionsClasses; ?>">
....
</div> <!-- end: actions -->
Note: It is best to first copy the entire list.phtml file to your own sub-theme
and make the changes there.
In your sub-themes list.phtml file just cut the section I mentioned above and move it up to somewhere around line 216 of the file.
Paste it right after the beginning of the <list class="item"> element and before the <div class="product-image-wrapper"....>, just like this:
<li class="item">
<!-- PUT THE CODE HERE -->
<div class="product-image-wrapper" style="max-width:<?php echo $imgWidth; ?>px;">
Also don't forget to add this in your custom.css style sheet:
.products-grid .actions {
margin: 0 0 10px;
}
This should do the trick for you!
How to set the width of popup in % ? I have tried giving width:80% of the popup div. It works fine in a desktop browser, but in mobile browser it squezees automatically.
here is the markup :
<div data-role="popup" style="width:80%;left:auto !important;right:0 !important;" id="help-dialog" data-overlay-theme="a" data-theme="a" data-dismissible="false" data-transition="none">
here is a screenshot :
Working example: http://jsfiddle.net/vds2U/61/
When changing jQuery Mobile CSS you need to be careful, specially when working with percentages. Only during pageshow event we can calculate correct page dimensions, ipso facto only at this point we can set percentage values to inner page content.
Problem with mobile devices is their sluggishness, it takes time for pageshow event to trigger.
So best course of action requires programatically solution:
HTML :
Some dummy popup:
<div data-role="popup"id="help-dialog" data-overlay-theme="a" data-theme="a" data-dismissible="false" data-transition="none" data-position-to="window">
<div data-role="header" data-theme="a" class="ui-corner-top">
<h1>Popup</h1>
</div>
<div data-role="content" data-theme="d" class="ui-corner-bottom ui-content">
<h3 class="ui-title">Focused Field</h3>
<p>
<input type="text" id="popup_input" />
</p> Close
</div>
</div>
JavaScript:
$(document).on('pageshow', '#index', function(){
var content_width = $.mobile.activePage.find("div[data-role='content']:visible:visible").outerWidth();
$('#help-dialog').css({'width':content_width*0.8});
});
For this solution to work, it MUST be executed during pageshow event. This solution also works on mobile devices.
One last thing, use data-position-to="window" attribute in your popup <div> if you want it centered.
There is no need to change the jQuery Mobile CSS, you can simply override it.
What's causing you problems is that jQuery mobile automatically puts your popup div in a container. If you want to change the width of your popup div you need to target the width of its container.
From jQuery Mobile docs:
The popup consists of two elements: the screen (...) and the container, which is the popup itself. If your original element had an id attribute, the screen and the container will each receive an id attribute based on it. The screen's id will be suffixed with "-screen", and the container's id will be suffixed with "-popup".
In your case, giving
#help-dialog-popup {
width: 80%;
left: auto;
right: 0;
}
Should do the trick.
I know this is an old post, but I run into the same problem right now. To create a popup that will look perfect on mobile but not too big for computer screen I use a class like dialog-medium below. This way you force the outside container to adjust size and to calculate the right position on screen. You can use 80vw to resolve the initial request or any percentage you want, but never use a higher percentage.
.dialog-medium {
width:90vw;
max-width:35em;
}
With browser inspection tool (ex. right-click -> Inspect element) you will find the class that popup uses.
data-role="popup" normally uses the .ui-popup-container.
So you add into style tag of your page something like the following.
.ui-popup-container {
height: 90vh;
width: 90vw;
}
In the above example, popup will be 90% of the viewport's size. Assuming that you ve written the tag.
If you want to have different size on desktop and mobile devices (you should), use the following:
#media screen and (max-width: 1000px) {
.ui-popup-container {
height: 90vh;
width: 90vw;
}
}
#media screen and (min-width: 1001px) {
.ui-popup-container {
height: 60vh;
width: 60vw;
}
}
In the above example, popup will be 90% of the viewport's size on mobile screens (less than 1001px width) and 60% of viewport's size on big screens (computer)
I have the following HTML and CSS:
<button id="myBtn" dojoType="dijit.form.Button">Testing</button>
#myBtn {
margin-left: 100px;
}
The CSS is supposed to push the button in 100px. But since dijit applies some extra layers of HTML around the button, the button gets a 100px padding.
JSbin to show the problem
edit: Found one (not IE6-compatible) solution:
[widgetid=myBtn] { margin-left: 100px; }
see above :-) Surround with a DIV and use that DIV in your static CSS.
I think decorating with HTML may actually be a simpler solution than trying to bake more into the widget or the widget's template.
Instead of applying the style by ID, do it through a class.
Stylesheet:
.myBtn { margin-left: 100px; }
Code:
<button class="myBtn" dojoType="dijit.form.Button" id="myBtn">Testing</button>
http://jsbin.com/ejoma/2
In this case you should not add the margin-left to the button itselft but to the additional HTML araound the button that is created. Try this:
.dijitLeft{
margin-left: 100px;
}
But this will indeed add a margin to every button. If you don't want that, add the margin to the parent span using JavaScript after the additional HTML was created.
Inline style is working.
<button id="myBtn" dojoType="dijit.form.Button" style="margin-left:100px">Testing</button>