I want to have a search input expand & transition on the click of an external button(icon) instead of just appearing/disappearing on click. How would one go about doing this. Either with pure CSS or in an Angular 7 animation way. I'm learning Angular for the first time.
Thanks
I want it to do something just like the search bar on this site.
https://theother98.com/
What I Have Thus Far w/ Angular 7
NAV.COMPONENT.HTML // in order to toggle hidden or shown searchbar
<div href="#" (click)="onToggleSearch()" class="search-icon"><i class="fa fa-search"></i></div>
<input type="text" [ngClass]="toggleSearch ? 'show' : 'hide'" name="search" placeholder="What are you looking for?">
NAV.COMPONENT.TS // some JS that allows the toggle method to work
export class NavComponent implements OnInit {
toggleSearch: boolean = false;
constructor() { }
ngOnInit() {
}
onToggleSearch() {
this.toggleSearch = !this.toggleSearch;
}
NAV.COMPONENT.SCSS // basic scss of my searchbar
input {
flex: 1;
z-index: 999;
font-size: 14px;
width: 180px;
border: none;
outline: none;
padding: 8px;
margin-right: 10px;
transition: all 0.15s ease-in-out;
}
I figured it out for anyone who had similar dilemma. What I did was this.
.show {
display: block;
max-width: 200px;
transform: scale(1);
}
.hide {
display: none;
max-width: 0px;
transform: scale(0);
}
input {
flex: 1;
z-index: 999;
font-size: 14px;
width: 180px;
border: none;
outline: none;
padding: 10px 8px;
margin-right: 10px;
display: block;
transition: all 0.3s ease-in-out;
}
When defining the CSS without transform:scale() the input will not be completely hidden when .hide is added to the element. Also, when you add a max height & max width and then click the button to display the searchbar... The input will not transition fluidly, instead it expands to the max height and THEN to the max width, in a very inelegant way. Finally, adding display:block to the input element is essential.
Thanks for the help everyone!
You are adding the classes hide and show. Therefore, having a max-height defined in those classes and a display of block on the item that will be "moving" should allow your transition to work. For example:
.hide {
max-height: 0;
}
.show {
max-height: 1000px;
}
input {
flex: 1;
z-index: 999;
font-size: 14px;
width: 180px;
border: none;
outline: none;
padding: 8px;
margin-right: 10px;
transition: all 0.15s ease-in-out;
display: block;
}
Related
we're trying to create a checkbox to look like the expand/collapse button and have a section appear/hide based on the checkbox state....so we made a special format for checkboxes called 'Expand Collapse' and placed it in the Skin in order to apply more styling on it via CSS.
We already have a special customization in place for all checkboxes in the application (code below)... we want to create a similar customization but with different backgrounds for the 'expand_collapse" class... (screenshot below)
would appreciate some help writting that in css (any code I write keeps applying to all checkboxes and not one in specific...)
Update Solution [6/17]:
thanks to the reply on here I was able to create the following helper class (checkbox-expand) and apply it in the Advanced Presentation Options for the checkbox
/****************************************
Type: helper-class
Name: checkbox-expand
Category: cell
Description: Applies styles to the checkbox control to display it as a expand
*********************************************************/
.checkbox-expand,
.checkbox-expand > .checkbox {
position: relative;
}
.checkbox-expand input.checkbox[type="checkbox"],
.flex.content > .flex.content-item .checkbox-expand input.checkbox[type="checkbox"] {
min-width: 0!important;
margin: 0!important;
font-size: 0;
width: 0!important;
height: 0!important;
border: 0!important;
}
.checkbox-expand input.checkbox[type="checkbox"],
.checkbox-expand input.checkbox[type="checkbox"]::before,
.checkbox-expand input.checkbox[type="checkbox"]::after {
margin: 0;
cursor: pointer;
vertical-align: middle;
line-height: 30px;
}
.checkbox-expand .checkbox[disabled],
.checkbox-expand .checkbox[disabled]::before,
.checkbox-expand .checkbox[disabled]::after {
pointer-events: none;
}
.checkbox-expand input.checkbox[type="checkbox"] {
position: relative;
padding-left: 54px;
display: inline-block;
z-index: 2;
-webkit-tap-highlight-color: transparent;
min-height: 42px;
font-size: 18px/* adjust as preferred - is not inherited */
}
.checkbox-expand input.checkbox[type="checkbox"]::before,
.checkbox-expand input.checkbox[type="checkbox"]::after {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
transition: all .15s;
}
.checkbox-expand input.checkbox[type="checkbox"]::after {
border-radius: 15px;
width: 24px;
height: 24px;
margin: 2.5px;
background: url('webwb/ArrowDown.svg') no-repeat 50% 50% !important;
}
.checkbox-expand input.checkbox[type="checkbox"]:checked::before {
background-color:transparent;
background-image: none;
border-color: transparent;
color: transparent;
height: 30px;
width: 50px;
margin: 0;
}
.checkbox-expand input.checkbox[type="checkbox"]:checked::after {
-moz-transform:scaleX(-1) scaleY(-1);
-o-transform:scaleX(-1) scaleY(-1);
-webkit-transform:scaleX(-1) scaleY(-1);
transform:scaleX(-1) scaleY(-1);
}
Go to Presentation tab of Checkbox Control.
Go to the Advanced Presentation Option
In the Cell read-write classes and Cell read-only classes give a css class name. For example regular-checkbox.
Now go to CSS file where you have customized the Checkboxes.
Replace input[type="checkbox"] with .regular-checkbox input[type="checkbox"] and refresh the browser screen on which that check box is present to see the results.
Now you can use this CSS class in specific checkboxes.
im trying to style an input type='range' i am able to style the runnable track but for some reason the thumb isnt getting styled fully
this is my code:
<input type="range" min="0" max="100 " value="50" id="slider" class="volume">
#slider {
width: 0;
opacity: 0;
transform: translateX(-50px);
position: absolute;
transition: 0.5s;
}
#slider::-webkit-slider-runnable-track {
-webkit-appearance: none;
height: 3px;
background-color: var(--white2);
}
#slider::-webkit-slider-thumb {
-webkit-appearance: none;
height: 7px;
width: 7px;
transform: translateY(-5px);
background-color: var(--white);
border: 1px solid;
}
somehow the transform: translateY(-5px); is getting applied but nothing else is.
Nevermind, it was an issue cause by an experimental chrome flag :/ sorry for wasting your time.
Routine label for forms are always on top of them, but I would like to know how to put label like outline text specially when you have WP Form plugin in Wordpress.
This is what I mean:
I know how to do it with html and css but it is not easy with WP Form:
I couldn't find it in documentation.
I actually created this in a recent project, which were I used Contact Form 7 (I prefer that plugin instead of WP Form). But nevertheless, u can achieve something like this with simple CSS, HTML and a little bit of JavaScript. Run the code-snippet for yourself and see what I did.
What we actually did is:
Hide the placeholder with: opacity 0, to prevent accessibility loss (people who are blind, can actually hear the placeholder if they focus on the input.
Create an floating label, that comes after the input, so it is on-top of the input.
Style the floating label based on the current input states. If it's active, then it goes to the top.
Then, when focussing the input, the JavaScript function will trigger and it will look if the input is still empty- or not. If it's not empty: add the class 'is-not-empty'.
With that class we can say to the label: Stay on top, my man!
const wrappers = document.querySelectorAll('.input-wrapper');
wrappers.forEach( (wrapper) => {
input = wrapper.children[0];
input.addEventListener('input', (e) => {
if (e.target.value !== '') {
wrapper.classList.remove('is-empty');
wrapper.classList.add('is-not-empty');
} else {
wrapper.classList.add('is-empty');
wrapper.classList.remove('is-not-empty');
}
});
});
.form-control {
margin-bottom: 18px !important;
height: 64px;
margin-top: 0 !important;
color: var(--bs-dark) !important;
}
.form-control.wpcf7-textarea {
height: auto;
}
.form-control::placeholder {
/* Chrome, Firefox, Opera, Safari 10.1+ */
opacity: 0;
}
.form-control:-ms-input-placeholder {
/* Internet Explorer 10-11 */
opacity: 0;
}
.form-control::-ms-input-placeholder {
/* Microsoft Edge */
opacity: 0;
}
.form-wrapper .input-wrapper {
position: relative;
}
.form-wrapper input:focus ~ .floating-label, .form-wrapper textarea:focus ~ .floating-label, .form-wrapper .is-not-empty .floating-label {
top: -13px;
bottom: 10px;
left: 20px;
font-size: 14px;
opacity: 1;
background: #fff;
height: 30px;
color: #333;
padding: 6px;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
}
.form-wrapper .floating-label {
position: absolute;
pointer-events: none;
left: 20px;
top: 23px;
transition: 0.2s ease all;
white-space: nowrap;
max-width: 61vw;
overflow: hidden;
}
<div class="form-wrapper">
<div class="input-wrapper">
<input type="email" name="emailadres" size="40" minlength="5" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-email form-control" id="emailadres" aria-invalid="false" value=''>
<label for="emailadres" class="floating-label">Your mail address here</label>
</div>
</div>
I'm a beginner, i searched a lot for an answer on the internet but none of them managed to clarify why the transition doesn't work.
HTML:
<li><i class="material-icons menu-bar" id="menu-bar">menu</i></li>
<ul class="menu-bar-content hide" id="menu-bar-content">
This is my Js :
const menuBar = document.getElementById('menu-bar');
const menuBarContent = document.getElementById('menu-bar-content');
var menuOpen = false;
menuBar.addEventListener('click' , menuBarBtn)
function menuBarBtn() {
if ( menuOpen == false) {
menuBar.innerHTML = '<li><i class="material-icons undo-icon">undo</i></li>';
menuBarContent.className = 'menu-bar-content';
menuOpen = true;
}
else {
menuBar.innerHTML = '<li><i class="material-icons menu-bar" id="menu-bar">menu</i></li>';
menuBarContent.className = 'menu-bar-content hide'
menuOpen = false;
}
};
And this is my Css:
.menu-bar {
display: inline-block;
vertical-align: middle;
float: right;
color: white;
margin: -1.45% 0.7%;
font-size: 23px !important;
transition: .4s;
}
.undo-icon {
display: inline-block;
vertical-align: middle;
float: right;
color: #1ec7b9;
margin: 0.9% 3%;
transform: rotateZ(43.2deg);
font-size: 14px !important;
border: 2px solid rgb(255, 255, 255);
border-radius: 70%;
padding: 1.5px;
transition: .4s;
}
After the icons switch with each other, i wanted to do it with a transition effect. Thank you in advance!
The transition is not happening because the element is completely removed/replaced with another onclick.
It is CSS properties that transition and the browser thinks it's got a completely new element, not one that is to be transitioned in some way.
What we do is have both li elements in the document all the time, but one of them will be hidden. To do this gradually we can use opacity: 0 alongside the rotation in a new class which is called faded here.
On a click we don't replace the li elements but we set the one that has not been clicked to have class faded - it will rotate and end up invisible with opacity: 0 and we remove the class faded from the other li element so it will rotate back to normal and with normal opacity.
Javascript has a handy function, toggle, for adding and removing a class so we don't have to remember which element is hidden and which is in view - having or not having class faded is enough.
Here is the snippet. Note, the body has been given a background-color just so we can see the white menu and the white border. Also I do not have access to whatever icons you are using so the i elements are replaced with spans just for this demo.
const menuBar = document.getElementById('menu-bar');
const undoBar = document.getElementById('undo-bar');
menuBar.addEventListener('click' , menuBarBtn);
undoBar.addEventListener('click' , menuBarBtn);
function menuBarBtn() {
menuBar.classList.toggle('faded');
undoBar.classList.toggle('faded');
};
body {
background-color: gray; /* just for this test so we can see the white menu */
}
.menu-bar {
display: inline-block;
vertical-align: middle;
float: right;
color: white;
margin: -1.45% 0.7%;
font-size: 23px !important;
transition: .4s;
}
.undo-icon {
display: inline-block;
vertical-align: middle;
float: right;
color: #1ec7b9;
margin: 0.9% 3%;
font-size: 14px !important;
border: 2px solid rgb(255, 255, 255);
border-radius: 70%;
padding: 1.5px;
transition: .4s;
}
.faded { /* added this so when an element has class="faded" it cannot be seen and it is rotated */
opacity: 0;
transform: rotateZ(43.2deg);
}
<ul class="menu-bar-content" id="menu-bar-content" style="margin-top:30px;"> <!-- added just for this tesmargin t so we could see the white menu word in the snippet -->
<li><span class="menu-bar" id="menu-bar">menu</span></li> <!-- remember to put back the <i icon calls in here in place of the spans -->
<li><span class="menu-bar undo-icon faded" id="undo-bar">undo</span></li> <!-- ...and we start this off as faded so it isn't seen to begin with -->
</ul>
How can I override the default popup for a required field on a HTML5 form?
Example: http://jsfiddle.net/uKZGp/ (make sure you click the submit button to see the popup)
The HTML
<form>
<input type="text" name="name" id="name" placeholder="Name*" required="required" />
<input type="submit" />
</form>
NOTE: You must view this with a HTML5 browser like Google Chrome or FireFox.
This link doesn't solve my question but it might make someone think outside of the box:
http://www.the-art-of-web.com/html/html5-form-validation/
http://adhockery.blogspot.com/2011/03/styling-with-html5-form-validation.html
It's impossible to change the validation style with only HTML5/CSS3.
It's part of the browser. The only attribute I figured out to change is the error message by using this example:
document.getElementById("name").setCustomValidity("Lorum Ipsum");
But, as shown in this example : http://jsfiddle.net/trixta/qTV3g/, you can override the panel style by using jQuery. This is not a plugin, it's a core functionality, uses a DOM lib called Webshims and, of course, some CSS to style the popups.
I found that very useful example in this bug post titled Improve form validation error panel UI.
I think this is the best solution you can find and only way to override the basic (ugly) error panel.
Regards.
I'm not sure why, but ::-webkit-validation-bubble-message { display: none; } wouldn't work for me.
I was able to get the desired result (tested in FF 19, Chrome Version 29.0.1547.76 m) by preventing the default behavior of the invalid event, which does not bubble.
document.addEventListener('invalid', (function(){
return function(e){
//prevent the browser from showing default error bubble/ hint
e.preventDefault();
// optionally fire off some custom validation handler
// myvalidationfunction();
};
})(), true);
Hope that helps others - I looked everywhere for this.
For webkit, you can use ::-webkit-validation-bubble-message. For example to hide it:
::-webkit-validation-bubble-message { display: none; }
There are also:
::-webkit-validation-bubble-arrow-clipper{}
::-webkit-validation-bubble-arrow{}
::-webkit-validation-bubble{}
::-webkit-validation-bubble-top-outer-arrow{}
::-webkit-validation-bubble-top-inner-arrow{}
::-webkit-validation-bubble-message{}
Update: Chrome does not allow styling form validation bubbles anymore: https://code.google.com/p/chromium/issues/detail?id=259050
For firefox you can experiment with :-moz-placeholder {}.
The current default email validation is currently one of the ugliest things I have ever seen Google design!
However it seems to be contained in a standard div so you can make some changes to it, if you remember to then reset these values.
I've found you can alter the background, font size and colour, border and shadow, like so
div {
background: rgba(0,0,0,0.8);
color: #333;
font-size: 11px;
border: 0;
box-shadow: none;
}
If you then overwrite these for divs inside the html tag, then only the validation is ultimately affected.
html div {
background: rgba(0,0,0,1);
color: #000;
font-size: 12px;
}
Unfortunately some of the key attributes that you'd want to change, such as margin and font-weight, cannot be altered.
NB. This technique currently only works for Chrome (12), i.e. not work for Firefox 4, Opera 11 or Safari (Win 7).
Appended a class to the input type. and displayed message there .Hope that helps after little customization. working codepen:
document.querySelector('#frm').addEventListener('submit', e => {
e.preventDefault();
e.currentTarget.classList.add('submitted');
});
body {
font-family: Helvetica, sans-serif;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
overflow: hidden;
width: 100%;
height: 100vh;
background: #ffa500;
}
form > div {
position: relative;
margin-bottom: 10px;
}
.theTooltip {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
will-change: opacity, visibility;
max-width: 250px;
border-radius: 5px;
background-color: rgba(0,0,0,0.7);
padding: 15px;
color: #fff;
box-sizing: border-box;
display: inline-block;
position: absolute;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-transform: translate(15%, -50%);
transform: translate(15%, -50%);
top: 50%;
left: auto;
right: auto;
bottom: auto;
visibility: hidden;
margin: 0;
opacity: 0;
-webkit-transition: opacity 0.3s ease-out;
transition: opacity 0.3s ease-out;
z-index: 100;
}
.theTooltip:after {
content: '';
position: absolute;
width: 0;
height: 0;
top: 50%;
margin-top: -10px;
left: -10px;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right: 10px solid rgba(0,0,0,0.7);
}
label {
display: inline-block;
vertical-align: center;
}
input {
background: #fff;
border: 1px solid transparent;
cursor: pointer;
display: inline-block;
overflow: visible;
margin: 0;
outline: 0;
vertical-align: center;
text-decoration: none;
width: auto;
border-radius: 3px;
cursor: text;
padding: 7px;
}
input:focus,
input:active {
outline: none;
}
.submitted input:invalid {
border: 1px solid #f00;
}
.submitted input:invalid ~ .theTooltip {
visibility: visible;
opacity: 1;
}
.submitted input:valid ~ .theTooltip {
-webkit-transition: opacity 0.3s, visibility 0s 0.3s;
transition: opacity 0.3s, visibility 0s 0.3s;
}
<form id="frm" action="action">
<div>
<label>Email</label>
<input type="email" required="required"/><span class="theTooltip">Invalid email</span>
</div>
<div>
<button formnovalidate="formnovalidate">OK</button>
</div>
</form>
I understand that this is a rather old question but I have found this library that I think this may be beneficial to other that find this.
http://afarkas.github.io/webshim/demos/index.html