I'm having multiple forms in an expansion, and I was using this code, for a date picker,
<mat-form-field>
<input formControlName="date" matInput placeholder="Dátum" type="date">
</mat-form-field>
Which works totaly fine, the expansion doesn't hide it (have a look), but then I had start and end values for both date and time, so I switched to ngx material daterangepicker.
My only problem is that the expansion hides the daterangepicker (have a look), so the daterangepickers code looks like this:
<mat-form-field>
<input
matInput
ngxDaterangepickerMd
name="daterange"
placeholder="Choose date"
applyLabel="Okay"
startKey="start"
endKey="end"
firstMonthDayClass="first-day"
lastMonthDayClass="last-day"
emptyWeekRowClass="empty-week"
lastDayOfPreviousMonthClass="last-previous-day"
firstDayOfNextMonthClass="first-next-day"
[autoApply]="options.autoApply"
[linkedCalendars]="options.linkedCalendars"
[singleDatePicker]="options.singleDatePicker"
[showDropdowns]="true"
formControlName="date"
[showWeekNumbers]="options.showWeekNumbers"
[showCancel]="options.showCancel"
[showClearButton]="options.showClearButton"
[showISOWeekNumbers]="options.showISOWeekNumbers"
[customRangeDirection]="options.customRangeDirection"
[lockStartDate]="options.lockStartDate"
[closeOnAutoApply]="options.closeOnAutoApply"
[opens]="opens"
[drops]="drops"
[timePicker]="timePicker"
/>
</mat-form-field>
I have tried to give it a custom z-index, like:
.md-drppicker {
z-index: 9999;
}
ngx-daterangepicker-material {
z-index: 9999;
}
But that didnt solve the problem, tried messing with the display/position too, but I can't fix it.
Any idea what's wrong?
Edit: Here's a better picture for the daterange picker problem
You need to use the overflow attribute as there is no space for the calendar. I think it will resolve your issue.
.md-drppicker {
z-index: 9999;
overflow: auto; // also try overflow-y;
}
ngx-daterangepicker-material {
z-index: 9999;
overflow: auto; // also try overflow-y;
}
I would suggest you to attach a stackblitz instance if issue still persist.
I'm using version the ngx-daterangepicker-material 2.4.1 on Angular 6.1.10
The issue for us was with the use of MatInput and angular-split-ng6.
The css fix for our implementation was the following
.md-drppicker.drops-down-right.ltr.shown.double.show-ranges {
position: fixed;
}
After using the above our calendar rendered correctly over the neighboring layer and did not wrap the calendar when the area where it was launched from is smaller than the required width for displaying the calendars side by side.
Related
I'm using NgxAutocomPlace module in my Angular App, the following module work with google autocomplete API by generating .pac-container in which it shows autocomplete results.
The issue is that on mobile the dropdown goes above instead of below of the input and it's unusable for the final user, it looks like this:
And here is how's my code looks like:
<div class="container-indirizzo mb-3">
<label>Indirizzo di consegna</label>
<div class="inside-indirizzo">
<div class="indirizzo">
<input
*ngIf="addressOptions !== null"
type="text"
class="form-control"
required
placeholder="es. Via Disraeli"
formControlName="indirizzo"
ngxAutocomPlace
[options]="addressOptions"
(selectedPlace)="addressChange($event)"
/>
</div>
<div class="civico" *ngIf="isCivico">
<input type="text" class="form-control" formControlName="nciv" placeholder="N°" autofocus />
</div>
</div>
</div>
Is there a way to set the position of that dropdown under the <input>?
EDIT 1:
The issue happens on scroll or in mobile devices as the virtual keyboard is up, so the problem is the position set to pac-container when is triggered
EDIT 2:
I'm trying to do something like this on Address change and on scroll but even this doesn't have any effect:
const top = this.indirizzo.nativeElement.getBoundingClientRect().top ;
const pacContainer = document.querySelector('.pac-container') as HTMLElement;
if (pacContainer) {
console.log(window.scrollY + top + 60);
pacContainer.style.top = window.scrollY + top + 60;
}
Where indirizzo is Div where input is placed.
EDIT 3:
the .pac-container is generated under <body> so i think by forcing it be rendered under <div class="indirizzo"> will solve the issue...
EDIT 4:
SOLVED by setting top to pac-container to fixed position of X pixel from top of the screen to bottom of input, but still looking for a better solution.
(so as from top 0 to end of my input there are 465px i just set .pac-container top: 465px) but as on some screens that height could be lower (some mobile 450 some other 460 other 470) the dropdown is still drawn badly..
If you are using Angular material this will help
.pac-container {
z-index: 100000;
}
If you are using Bootstrap, this will help you.
::ng-deep .pac-container {
z-index: 100000;
}
Perhaps something like this when the elements have loaded could solve the problem.
const pacContainer = document.querySelector('.pac-container') as HTMLElement;
const body = document.body as HTMLElement;
const indirizzo = document.querySelector('.indirizzo') as HTMLElement;
const clone = pacContainer.cloneNode(true);
indirizzo.appendChild(clone);
body.removeChild(pacContainer);
.pac-container CSS should contain position: relative.
I also experienced such issue with bootstrap and angular material ui.
With these 2 cases, I used the following css.
html {
height: 100%;
min-height: 100%;
}
Try this:
/deep/ .pack-container{
z-index: 10000 !important;
position: fixed !important;
}
I have modal in which i have angular-material autocomplete. It's html is like this
<mat-form-field class="example-full-width dummy-input-field" floatLabel="never">
<input matInput class="custom-input" (blur)="getValue()" [matAutocomplete]="auto" [formControl]="stateCtrl">
</mat-form-field>
<mat-autocomplete #auto="matAutocomplete" style="z-index: 2000;">
<mat-option *ngFor="let state of filteredStates | async" [value]="state.name">
<img class="example-option-img" aria-hidden [src]="state.flag" height="25">
<span>{{state.name}}</span> |
<small>Population: {{state.population}}</small>
</mat-option>
</mat-autocomplete>
But issue here is that my autocomplete results list is showing behind modal like this
You can see at the top left behind screen overlay there is a list showing. Basically this list is of material-autcomplete suggestion list. I have tried these css to change z-index of autocomplete
.md-autocomplete-suggestions-container {
z-index: 100000 !important;
}
.cdk-overlay-container {
z-index: 999999 !important;
}
But none of the solution is working. I am not using bootstrap moda. I am using npm simple-modal. How can i fix this issue?
in your scss or css file of component add below
/deep/ .cdk-overlay-container { z-index: 9999; }
We need to get the bootstrap's z-index dynamically and increment it with some arbitrary number and set to the time-picket something like below:
$(document).on('show.bs.modal', '.modal', function (event) {
const zIndex = 1045 + (10 * $('.modal:visible').length);
// this zIndex can be assigned to the time-picker
$(this).css('z-index', zIndex);
setTimeout(function () {
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
}, 0);
});
This will solve your problem, but I suggest to use only one UI lib for the design :)
i have this search bar in my application which i want to modify:
Right now the "X"-Icon is visible from the beginning even tho it does nothing before an input was done, so i want to make it appear AFTER the user starts entering text.
The icon is a SVG i added and styled seperatly.
I don't realy know how i can do this, i thought its easy and i can just use something like "::after" but it seems that this it not possible with input fields.
Ps.: im an absolute beginner in CSS so please have mercy.
Best way to achieve your requirement would be to have different classes which shows/hides the icon by checking when input is not empty in JS.
If you want to achieve without using JS you can target the adjacent button element when the input is focussed and add ::before pseudo element and style it.
input:focus+button:before {
content: "X";
position: absolute;
left: 0;
color: red;
}
It's not possible with CSS. You would have to use Javascript.
Javascript
// set the id of the x button to x-button
// set the id of the input field to input
var x_button = document.getElementById("x-button");
var input = document.getElementById("search-input");
input.oninput = function(){
if(this.value) x_button.classList.add("visible");
else x_button.classList.remove("visible");
}
CSS
.x-button { display:none;}
.visible {display:block;}
it is possible if you wanna do it using only css.
#Search{
font-size:22px;
color:green;
background-image:url('images/search.jpg');
background-repeat:no-repeat;
background-position:center;outline:0;
}
#Search::-webkit-search-cancel-button{
position:relative;
right:20px;
}
<input id="Search" name="Search" type="search" placeholder="Search" />
I want to always show up/down arrows for input "number" field. Is this possible? So far I haven't had any luck...
http://jsfiddle.net/oneeezy/qunbnL6u/
HTML:
<input type="number" />
CSS:
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: "Always Show Up/Down Arrows";
}
You can achieve this (in Chrome at least) by using the Opacity property:
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
opacity: 1;
}
As stated above, this will likely only work in Chrome. So be careful using this code in the wild without a fallback for other browsers.
I tried this and it worked
input[type=number]::-webkit-inner-spin-button {
opacity: 1
}
</style>
<input type="number" value="1" min="1" max="999">
Found Here
If you're trying to get the same appearance across different browsers you may be forced to use a plugin/widget or build one yourself, the main browsers all seem to implement number spinners differently.
Try jQuery UI's spinner widget it offers a lot more versatility when it comes to styling.
Working Example
<p>
<label for="spinner">Select a value:</label>
<input id="spinner" name="value" />
</p>
$("#spinner").spinner();
I tried this and it's working
input[type=number]::-webkit-inner-spin-button {
opacity: 1
}
If you don't mind the focus on your input, do
document.getElementById(<id>).focus();
Chrome has apparently added a dropdown arrow to text inputs that reference a <datalist>. It's appearing in Chrome 34 (Canary) but not in the current stable build (Chrome 31).
It appears only when the text field is focused (see update) and is applied to both input types text and search.
It could be worse as far as native browser implementations go, but as you can see in the image, it conflicts with my design specs.
Does anyone know how to remove or replace this new feature?
<datalist id="list"><option value="foo"><option value="bar"></datalist>
<input type="text" list="list" name="field" maxlength="50" autocomplete="off" spellcheck="off" placeholder="Jump To">
Update:
The arrow also appears when the field is hovered (not just focused) and unfortunately also has its own background color when the button itself is hovered:
Thanks to the comment by alexander farkas, here is the style rule to remove the arrow:
input::-webkit-calendar-picker-indicator {
display: none;
}
As others have mentioned ::-webkit-calendar-picker-indicator { display: none } works at removing the arrow it would also impact the html5 datepicker on a <input type="date">,
To remove just removing the datalist input would be:
[list]::-webkit-calendar-picker-indicator {
display: none;
}
Thanks to Cantera. I didn't want to get rid of the black arrow entirely, just the gray square surrounding it.
input::-webkit-calendar-picker-indicator {
background-color: inherit;
}
input::-webkit-calendar-picker-indicator {
opacity: 0;
}
Also removed the arrow for me and I found created a better clicking experience to still click where the arrow would be, you can even increase the the width and height of it > 1em and in the input maybe put a custom arrow as a background image, where the arrow would be.
input::-webkit-calendar-picker-indicator {
opacity: 0;
}
It's work for me; (use display:0 not work on chorme)
datalist::-webkit-calendar-picker-indicator {
display: none;
opacity: 0;
}
It is okay but this css code will hide any calander on page.
Like I'm using datepicker calender and this will also hide the controls including datalist and datetime picker.
Set the list option of parent input to be empty, <input list="" ... /> , eg :
<input
list=""
name="option"
id="input"
autocomplete="off"
>
<datalist id="datalist">
<option>Carrots</option>
<option>Peas</option>
<option>Beans</option>
</datalist>
see mdn customizing_datalist_styles example
try -webkit-appearance: none that should remove the default styles