I am trying to get the checked checkbox to show up on our website. If you go to this page and choose a pricing plan: https://www.shiftdivorceguide.com/submit-listing/ then scroll to the bottom of the next page we have two check boxes, "I agree" and "Already have an account".
When I check them they disappear and I want them to show with a check mark in them.
HTML for I agree checkbox
<div class="checkbox form-group col-md-4 check_policy termpolicy">
<input id="policycheck" type="checkbox" name="policycheck" value="true">
<label for="policycheck">
<a target="_blank" href="https://www.shiftdivorceguide.com/terms-and-conditions/" class="help">I Agree</a>
</label>
</div>
CSS:
.checkbox input[type=checkbox] {
display: none;
}
.checkbox label:before { /*This is the css code for the existing checkbox*/
content: "";
display: inline-block;
width: 20px;
height: 20px;
top: 3px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
-webkit-transition: all 0.1s ease;
-moz-transition: all 0.1s ease;
-o-transition: all 0.1s ease;
transition: all 0.1s ease;
border-radius: 2px;
}
If I change this to to display:inline a second smaller box displays and if I check it on I Agree it jumps to the right. When I check the box the :Before instance disappears in the code along with the box on the screen
I would like the nicer larger box (not the smaller box) to remain and show as checked when someone checks it.
Can anyone point me in the right direction on how to fix this?
Thanks in advance!
According to what I understood you want to hide the first checkbox when clicked and the second one to remain. If that's what you want here is a potential solution to your problem:
HTML
<form onSubmit="yourSubmitFunction()">
<div id="policycheck">
<input type="checkbox" name="policycheck" value="PolicyCheck" onclick="hidePolicyCheckbox()"> I agree
</div>
<div id="existingAccount">
<input type="checkbox" name="alreadyHaveAnAccount" value="alreadyHaveAnAccount"> Already have an account
</div>
<input type="submit" value="Submit">
</form>
and JavaScript
function hidePolicyCheckbox() {
var policyCheckbox = document.getElementById("policycheck");
if (policyCheckbox.checked === true){
policyCheckbox.style.display = "block";
} else {
policyCheckbox.style.display = "none";
}
}
If you want your second checkbox not to move up when the first one disappear you can use policyCheckbox.style.visibility = "hidden"; instead of policyCheckbox.style.display = "none";
Is this what you are trying to achieve?
Related
Here's the actual 'Swticher' Generator: https://proto.io/freebies/onoff/
I'm not clear on how to add text to the event - so when the switch is on default certain text is shown and vica versa.
Here's the HTML:
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
I tried to add the class to a < p > tag but no joy.
Thanks for all help.
You can copy paste the css used by the site through DevTools. Anyways, what they do is, initially they set the checkbox to checked which makes the margin-left to be 0 which shows the ::before pseudo-element that has "ON" text. And on not checked, margin-left is set to -100% which shows ::after pseudo-element that has "OFF" text.
Here's the relevant CSS -
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-inner::before {
content: "ON";
padding-left: 10px;
background-color: #34A7C1;
color: #FFFFFF;
}
.onoffswitch-inner::after {
content: "OFF";
padding-right: 10px;
background-color: #EEEEEE;
color: #999999;
text-align: right;
}
.onoffswitch-inner {
display: block;
width: 200%;
margin-left: -100%;
transition: margin 0.3s ease-in 0s;
}
Here's the entire code in JSFiddle - https://jsfiddle.net/0f4rbLmo/1/
Edit:
If you want to toggle a div based on the switch, you can define hidden class like -
.triggeredDiv.hidden {
display: none;
}
And then trigger it based on checkbox value in javascript when event is fired.
function toggleDiv() {
if (document.getElementById('myonoffswitch').checked) {
document.querySelector('.triggeredDiv').classList.remove('hidden');
} else {
document.querySelector('.triggeredDiv').classList.add('hidden');
}
}
document.getElementById('myonoffswitch').addEventListener("change", toggleDiv);
JSFiddle - https://jsfiddle.net/g7qm2txs/
I can't find a way to make an <input type="image> change into a color when the user clicks on it, meaning the space the image was occupying would be replaced by a plain color. My code is the following:
input:focus{
color:#0C6
}
and
<input type="image" src="image.jpg" />
You'll need a parent wrapper having the desired color,
and on input :focus make it transparent using opacity
.imageWrapper{
display: inline-block;
background: #0C6;
}
.imageWrapper input[type=image]{
vertical-align: top;
transition: 0.3s; /* fade nicely :) */
}
.imageWrapper input[type=image]:focus{
opacity: 0;
}
<span class="imageWrapper">
<input type="image" src="//placehold.it/60x60/f00">
</span>
For the following markup:
<div class="form-group">
<label class="control-label" for="email">Email Address</label>
<input type="text" name="email" id="email" placeholder="Email Address" class="form-control">
</div>
this is what is being readout by NVDA:
Firefox
Email Address Edit Blank
IE
Email Address Edit Blank
Chrome
Email Address Edit Email Address Blank
It seems that chrome is also reading out the placeholder text but Firefox and IE aren't. Removing placeholder text isn't an option since it is a requirement.
In this case, is there a way I can make Chrome not read the placeholder text?
<input aria-hidden="true" role="alert" class="range from hasDatepicker" type="text" value="" data-type="range" id="range-from" data-uniq-id="11/19/2020" name="range-from" aria-label="11/19/2020">
The solution to double-reading in the example above for me was to add aria-hidden = "true" great idea and it works.
Ok, so rather than manipulating your prefectly standards compliant HTML, I would simply understand the tools you're working with better. I've tried so many js hacks, but that's just what they are (hacks). Chrome tends to simply read the placeholder text. That's just it. Here are a couple references to check out. They are incredibly helpful.
browser/screenreader combos
aria support breakdown
However, if you REALLY wanted to fix this issue in Chrome, you would detect Chrome/webit (via How to detect chrome and safari browser (webkit))
var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
Then you could do one of these options:
REMOVE the placeholder text
REPLACE it with regular text, which would be appended/prepended directly after/before the input, you would format this in css to overlay on the input, use js to set aria-hidden="true" and then hide the text on input focus
Here's a plnkr to show how to do it: plnkr
****NOTE****
That plnkr is sloppy code. I would write a module to accept parameters so it can be used on any input.
This is kind of a late response to this question, but the better solution to prevent the text from being read out loud multiple times would likely be to not use the placeholder at all, but maybe dynamically position the label within the textbox like a placeholder.
$('#form').find('input').on('keyup blur focus', function(e) {
var $this = $(this),
label = $this.prev('label'),
val = $this.val();
if (e.type === 'keyup') {
if (val === '') {
label.removeClass('active highlight');
label.addClass('focused');
} else {
label.addClass('active highlight');
label.removeClass('focused');
}
} else if (e.type === 'blur') {
if (val === '') {
label.removeClass('active highlight focused');
} else {
label.removeClass('highlight focused');
}
} else if (e.type === 'focus') {
if (val === '') {
label.removeClass('highlight');
label.addClass('focused');
} else if (val !== '') {
label.addClass('highlight');
label.removeClass('focused');
}
}
});
#form {
padding: 40px;
width: 300px;
height: 75px;
margin: 40px 40px;
float: left;
}
#form .field-wrap {
position: relative;
margin-bottom: 40px;
}
#form .field-wrap label {
position: absolute;
transform: translateY(6px);
left: 13px;
transition: all 0.25s ease;
-webkit-backface-visibility: hidden;
pointer-events: none;
font-size: 22px;
}
#form .field-wrap label.active {
transform: translateY(-20px);
left: 2px;
font-size: 14px;
}
#form .field-wrap input {
font-size: 22px;
display: block;
width: 100%;
height: 100%;
padding: 5px 10px;
background: none;
background-image: none;
border-radius: 0;
transition: border-color .25s ease, box-shadow .25s ease;
}
#form .field-wrap input:focus {
outline: 0;
}
#form .field-wrap p.context {
font-size: 1em;
margin: .5rem 0rem 0rem 0rem;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="form">
<div class="field-wrap">
<label for="textField">Label Placeholder Text</label>
<input type="text" name="textField" id="textField" autocomplete="off" aria-describedby="textFieldDescription" />
<p id="textFieldDescription" class="context">Type in some text.</p>
</div>
</div>
Have you tried to delete placeholder on input focus? Something like:
<input type="text" name="email" id="email" placeholder="Email Address"
onfocus="this.placeholder=''"/>
It's not the best solution, but it can work for you.
When you click a link, a:active style of the clicked link is being applied. So when I've got a link which gets called and activated from the url using its name like whats shown below, why doesn't my code work?
.box{
display:block;
width:100px;
height:100px;
background:gray;
margin:20px 0px;
}
a{
-moz-transition:all 1s ease;
-webkit-transition:all 1s ease;
}
a:active{
background:orange;
}
<body>
user
<a class="box" name="user">userbox</a>
</body>
I want it to call a:active css for userbox when userbox is called from the url.
Is my code invalid or not an option for these kind of situations?
I think the pseudo-class you want is :focus. :active is applied while a link is being clicked.
-EDIT-
Of the browsers I tested, only Internet Explorer 11 focused the anchor when the URL was updated to include #user. You can use JavaScript to set a class as follows:
window.addEventListener('hashchange', function () {
var activeElement = document.getElementById(window.location.hash.substring(1));
if (activeElement) {
activeElement.className = 'active';
}
});
This would require using the following CSS:
.active {
color: orange;
}
And this assumes using id="user" instead of name="user" which both behave the same with regard to the URL hash.
I want it to call a:active css for userbox when userbox is called from the url. my code is invalid or it's not an option for this kinda situations?
You can't. :active means "While being clicked on or otherwise activated". It does not mean "Having an href attribute that resolves to the current URI".
Use some other mechanism, such as adding a class to the element in the HTML.
We can hack it, we have the technology.
In all seriousness you should use classes and Javascript for this solution, but I put a bit too much of my lunch time into this to just throw it away.
http://jsfiddle.net/DF4VG/
CSS:
#label {
display: block;
}
#label:hover {
cursor: pointer;
text-decoration: underline;
}
#container {
position: relative;
}
#wrapper {
z-index: 2;
position: relative;
}
#user {
border: none;
background: transparent;
position: absolute;
top: 0;
bottom: 0;
width: 100%;
z-index: 1;
transition: all 1s ease;
}
#user:focus {
background: orange;
}
HTML:
<form action="">
<label id="label" for="user">User</label>
<div id="container">
<div id="wrapper">
<p>There is some content in here</p>
<p>And some more</p>
<p>And so forth</p>
</div>
<input type="text" id="user" value="" readonly>
</div>
</form>
I am having a bit of trouble getting a form btn to stay to the right of its associated form input. It is fine when the browser is an appropriate size, however, when the browser is reduced, this btn moves onto a line below the input rather than staying to the left. I have tried pretty much everything I can think of, but I cant stop it from moving when the window is shrunk.
Any help would be greatly appreciated.
Here is the css:
#footer-newsletter form {
display: block;
vertical-align: baseline;
}
#footer-newsletter input {
display: inline;
width: 231px;
height: 19px;
background: #202020;
border:0;
margin:0;
padding:10px;
color: #A5A5A5;
font-size: 0.85em;
font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
-webkit-transition:background .3s ease-in-out;
-moz-transition:background .3s ease-in-out;
transition:background .3s ease-in-out;
float:left;
border-radius:0
}
#footer-newsletter button {
display: inline;
width:39px;
float:right;
height:39px;
text-indent:-9999em;
background:#202020 url(images/newsletter_arrow.png) no-repeat center center;
border:0;
margin-left:1px;
-webkit-transition:background .3s ease-in-out;
-moz-transition:background .3s ease-in-out;
transition:background .3s ease-in-out;
}
Here is the html:
<!-- BEGIN .four columns right #footer-newsletter -->
<div class="four columns right" id="footer-newsletter">
<h3>Newsletter</h3>
<p>Occasional email updates, no spam</p>
<form id="newsletter" method="post" action="http://innervisionsoftware.co.uk/wp-content/plugins/newsletter/do/subscribe.php" onsubmit="return newsletter_check(this)">
<input id="email" type="email" name="newsletter" value="Your email address" required>
<button type="submit">Submit</button>
</form>
</div>
<!-- END .four columns right #footer-newsletter -->
The container is merely a pecentage width of the larger container which is 100%.
I would usually put this code on a live site for the purposes of this question, but I cant access the usual sites from this network, so sorry about that.
Any help would be greatly appreciated.
It goes below because it's floated.
You have fixed width for your input and button so you can set a min-width to the container:
#footer-newsletter form {
min-width:295px;
}
An example http://jsfiddle.net/zX3F4/1/
Give it's parent (form#newsletter) a minimum width, when the screen size gets smaller than that size, the scrollbars will appear.
#newsletter { min-width: 300px; } /*adjust to your needs */