Is there any way to keep dropdown triangle (▼) displayed for multiple mode of ui-select?
<div ui-select multiple ng-model="selectedItems" class="form-control">
<div ui-select-match>
<span>{{$item.name}}</span>
</div>
<div ui-select-choices repeat="item in availableItems" >
<span>{{item.name}}</span>
</div>
</div>
I managed to steal the triangle from ordinary ui-select:
<i class="caret pull-right" ng-click="$select.toggle($event)"></i>
but having difficulties displaying it properly on the ordinary place to the right. Any tips? Thanks.
The solution I got so far: reused this caret class and made it displayed on top of the component using style position: relative; left: -1.5em;, placing the element right after ui-select (placing it straight inside ui-select is not possible because angularjs replaces it's content with own templates - so my caret comes after but then shifted left)
Also, I had to attach ng-click which does $select.toggle($event) to this caret element. As long as the $select is not available out of scope of ui-select, I had to introduce outer controller which includes both ui-select and caret elements - and simply assign $select a field within it using ng-init on ui-select.
So it looks something like:
<div ui-select multiple ng-model="selectedItems" class="form-control" ng-init="mySelect = $select">
<div ui-select-match>
<span>{{$item.name}}</span>
</div>
<div ui-select-choices repeat="item in availableItems" >
<span>{{item.name}}</span>
</div>
</div>
<span style="position: relative; left: -1.5em;" class="caret"
ng-click="mySelect.toggle($event)></span>
▼ is displayed only when dropdown is not opened. Also, clicking it requires some pixel-hunting (can be mitigated by putting the caret into a div that spreads vertical). So it's a partial solution.
The best approach I worked out is a scalable background SVG image applied using this CSS:
.select2-search-field {
width: 100%;
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='1em' height='1em' viewBox='0 0 13 6' fill='gray'><polygon points='0 1 8 1 4 5'></polygon></svg>");
background-repeat: no-repeat;
background-position-y: center;
background-position-x: right;
}
Related
I would like to display the hidden button content in my card when hovering over it. I am currently attempting to use the adjacent sibling selector to do this, by connecting a hover element (the card) to another element (the hidden button) to achieve this. The code is is as follows
<div class="container">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
<div class="card-white">
<div class="secret-button">
<img src="images/approve.svg" id="i">Hidden button
</div>
<img src="images/chococake2.jpg"
style="width: 245px; height: 191px;"
/>
<h3>Recipe</h3>
<h4>German Chocolate Cake</h4>
<p>5/5</p>
<p>reviews</p>
<p>make it again</p>
</div>
</div>
My hidden button is currently set as display none on my css purposely, but I would like to then make it visible by doing the below
.card-white:hover{
background-color: #8C8C8C;
border: 5px solid green;
text-decoration: none;
}
.secret-button{
display: none;
}
.card-white:hover + .secret-button{
display: block;
}
The issue is that despite my attempt above, this is not changing my html page. The plus button appears as orange on my sublime text, which suggests to me it does not like or recognize the selector as valid css code for some reason.
I think the main problem is that I may need to restructure the html/css as these two elements may not be proper siblings, but just want to know how best to go about this.
I created a dropdown menu that opens when you click on a text box, and then when you chose a string for that dropdown list, it puts it in the text box.
I would like to make that when you hover your mouse on the strings in the dropdown, they get slightly highlighted! how can I achieve this?
<div class="row">
<div class="col-xs-12 max300" uib-dropdown is-open="vm.descriptionDropdownOpen">
<textarea name="remarks" class="form-control" ng-model="vm.presence.description" ng-click="vm.toggleDescriptionDropdown()" autofocus></textarea>
<ul id="descriptionDropdown" uib-dropdown-menu>
<li ng-repeat="descr in vm.loadedDescriptions" ng-click="vm.presence.description = descr.text; vm.descriptionDropdownOpen = false;">
{{descr.text}}
</li>
</ul>
and the css to keep the dropdown aligned with the textbox:
#descriptionDropdown {
width: 100%;
line-height: 150%;
padding-left: 8px;
position: relative;
}
thank you very much
you can do something like this
#descriptionDropdown li:hover{
background-color:#eaeaea;
}
Change the color code to your desired color code.
And remove the padding from ul to avoid space around background when you hover. Instead, use padding on li
#descriptionDropdown li{
padding-left:8px;
}
You could add this css :
li:hover {
background-color: blue;
}
I am able to make input field with icon but I need the input field should be rounded corner ![enter image description here][1] and horizontally center width smaller as show in image .
please check the below image
Please check my search bar is smaller in width and horizontally centered having rounded corner .can we make this in ionic
here is my code
<ion-content>
<div class="list list-inset">
<label class="item item-input">
<img src="https://dl.dropboxusercontent.com/s/n2s5u9eifp3y2rz/search_icon.png?dl=0">
<input type="text" placeholder="Search">
</label>
</div>
</ion-content>
The answer is simple
first you need to put all you need inside ion-item tag and then you need some css properties to shape that ion-item
Example
HTML CODE :
<ion-item class="roundedInput">
<ion-label position="floating">Rounded Input</ion-label>
<ion-input></ion-input>
</ion-item>
CSS Code :
.roundedInput {
--border-color: var(--ion-color-medium-shade);
--border-radius: 3px;
--border-width: 1px;
--box-shadow: 2px gray;
--highlight-height: 0;
--background: #f8f9fa;
}
to take control of the item behavior you need some more CSS Codes
like this :
.roundedInput.ion-invalid.item-has-focus {
--border-color: var(--ion-color-danger-shade);
}
.roundedInput.ion-valid.item-has-focus {
--border-color: var(--ion-color-success-shade);
}
.roundedInput.ion-invalid.ion-dirty {
--border-color: var(--ion-color-danger-shade);
}
.roundedInput.ion-valid.ion-dirty {
--border-color: var(--ion-color-success-shade);
}
the label with floating position will increase the input height
if its not what you like , all you need to do is just change the position to static or with no position property.
or you can just use placeholder
Why not just set some attributes to your outer div and your inner label in your .css like
div#container{width: 300px; margin-left: auto; margin-right: auto;}
label#rounded{border-radius: 15px;}
Here's the pen. Is this what you're looking for?
I have a list of items (each of which includes multiple elements) where each item is clickable and switches view. Is there a way to get the ripple effect on the whole md-item-content? I tried class="ripple" but that was not sufficient.
<md-content>
<md-list layout="column" md-padding>
<md-item ng-repeat="resto in list.data.recommendations">
<a ui-sref="resto({qname: resto.qname})" class="ripple">
<md-item-content id="resto{{$index}}">
...
If you want to use ripple effect on specific elements you can use md-ink-ripple.
<div md-ink-ripple></div>
Just add a md-ink-ripple directive and .md-clickable class to the <md-list-item> element:
<md-list-item md-ink-ripple class="md-clickable">
<p>Foo</p>
</md-list-item>
Also you can set the font-weight to 500 if you wish (that is how a default clickable-item looks like).
The other answers cover most of the cases but you can also customize the color of the ripple effect by using
<md-list-item md-ink-ripple="#03A9F4">
<p></p>
</md-list-item>
This will give a light blue ripple color.
The team behind Angular Material wanted to keep this internal and reduce customization which is why they haven't documented it well. However, I thought it was a useful customization. Hope it helps! Cheers!
Actually, there's lack of documentation over this.
I was searching for a solution and found your ask here, so I went to check their source code.
You can use md-list > md-list-item with several restrictions. In your case, the idea is to get close to their docs menu, on sidenav (theirs is a directive called menu-link, on the link itself), and I've acomplished with some modifications in my original code (which were close to yours):
<md-list>
<md-list-item
ng-repeat="section in ::admin.sections"
ng-class="{
'active': $state.includes(section.active),
'disabled': section.disabled
}"
ng-click="!section.disabled && $state.go(section.state)">
<span ng-bind="::section.label"></span>
</md-list-item>
</md-list>
Basically, isn't all elements that are accepted as action-triggers inside md-list-item. md-checkbox and md-switch are the only childs that are accepted to do a process, inside preLink function on md-list-item directive.
The other way is to put a ng-click on the md-list-item itself, or in a child element, inside it.
The preLink process is a wrapper, using a "non-styled" button that do a "proxy" on the click, and visually acomplishes the ripple effect.
Other things, like attributes, too, aren't being transferred to this "proxy", so a disabled cannot be used directly, you need to simulate its results. In my case, I interrupt the ng-click action, and put a class into the element.
I would suggest using md-button if you want ripples instead of the anchor. Then just do your ui-router state change in the controller.
See https://github.com/angular/material-start/blob/master/app/index.html#L30 for an example.
<md-list layout="column" md-padding>
<md-item ng-repeat="resto in list.data.recommendations">
<md-button ng-click="vm.navigateToResto(resto)" ng-class="{'selected' : it === vm.selected }" id="resto{{$index}}">
...
</md-button>
</md-item>
</md-list>
Here is the best way to do it:
<div md-ink-ripple class="ripple">Div like an md-button</div>
add to your div md-ink-ripple directive
add ripple class to your div:
`
.ripple {
position: relative;
&:active > .wave {
animation: ripple 0.25s;
}
.wave{
position:absolute;
width:100%;
height:100%;
background-image: radial-gradient(circle, #000 10%, transparent 10.01%);
background-repeat: no-repeat;
background-position: 50%;
background-size: 0 0;
top:0;
left:0;
transform: scale(0);
opacity:0;
}
}
#keyframes ripple {
0% {transform: scaleX(0);}
50%{transform: scaleX(1);opacity:0.3;}
100%{transform: scaleX(1);opacity:0;background-size: 1000% 1000%;}
}
`
I want use ng-class to conditionally add a class to the accordion-heading, but it appears that not even setting a class explicitly on the element gets preserved. I have this:
<div accordion close-others="true">
<div ng-repeat="currItem in items" accordion-group>
<div accordion-heading class="myClass">My Heading {{$index}}</div>
<div class="accordion-inner myClass">asdf asdf asdf</div>
</div>
</div>
And the fiddle: http://jsfiddle.net/Zmhx5/1/
When I inspect the accordion heading element, the class myClass is nowhere to be found. Is there some reason I can't add classes to the accordion heading?
You can put the CSS inside the directive accordion-heading tags:
<accordion-heading>
<div class="myClass">My Heading {{$index}}</div>
</accordion-heading>
In Angular UI Bootstrap, they have created a directive for accordion-heading. Template for this is written in ui-bootstrap-tpls.js. Try to modify directive for accordion-heading.
I ran into the same issue trying to conditionally apply a background color to the heading with ng-class. This is a bit of a workaround, but it does the trick.
First we need to remove the padding from the heading. If you inspect it, you'll see that it generates a div with a .panel-heading class and a padding: 10px 15px (see note below). The padding is what causes issues when trying to apply a background to a nested div, so lets remove it.
.panel-heading {
padding: 0;
}
Now we can add our nested div and give it the same padding to get back our previous look.
<accordion-heading>
<div class="myClass" style="padding: 10px 15px">My Heading {{$index}} </div>
</accordion-heading>
Here's the updated jsfiddle
Note my code above is from a different version of ui-bootstrap. The classes were slightly different in this jsfiddle, so you will see a slightly different solution. The concept, however, is the same.
you could just apply your CSS to an outer div like this:
HTML:
<div ng-app="myApp" ng-controller="MyCtrl">
<div accordion close-others="true">
<div class="myClass" ng-repeat="currItem in items" accordion-group>
<div accordion-heading>
<div>My Heading {{$index}}</div>
</div>
<div class="accordion-inner">asdf asdf asdf</div>
</div>
</div>
</div>
CSS:
.myClass {
background-color: gray;
color: black;
}
.accordion-inner {
background-color: green;
color: black;
}
JS:
angular.module("myApp", ['ui.bootstrap'])
.controller("MyCtrl", function ($scope) {
$scope.items = [{}, {}, {}, {}];
});
then, change it to use ng-class and it should work just fine
pd: (Sorry about the bad english)