I have button on my html page, when i click on that button it show me outer line to button shown as below image.
here when i click on reset button it show me outer as above image.
Html code:
< input type="reset" value="" class="resetButton" />
css code:
.resetButton
{
margin: 0px;
background:url(../images/button/Reset2.png) no-repeat;
border: none;
width: 90px;
height: 32px;
cursor: pointer;
}
Use this:
input[type="reset"]:focus{
outline: none;
}
or just
input:focus{
outline: none;
}
if you don't want that outline to all the input types.
Just add display: block;
.resetButton
{
margin: 0px;
background:url(../images/button/Reset2.png) no-repeat;
display: block;
border: none;
width: 90px;
height: 32px;
cursor: pointer;
}
This is normally a chrome issue, the main thing to note here is that it is an outline not a border.
Try
.resetButton{ outline: none; }
For more info check out http://www.w3.org/TR/CSS2/ui.html#dynamic-outlines
Also check out this post on the dangers of removing the border completely
Google Chrome > Textboxes > Yellow border when active..?
Take a look on the outline CSS property.
To style a button that is being clicked, you can use :active pseudo-class.
Add an outline: none to your css:
.resetButton
{
margin: 0px;
background:url(../images/button/Reset2.png) no-repeat;
border: none;
width: 90px;
height: 32px;
cursor: pointer;
outline: none;
}
Try this.
.resetButton, .resetButton:visited
{
margin: 0px;
background:url(../images/button/Reset2.png) no-repeat;
display: block;
width: 90px;
height: 32px;
cursor: pointer;
border: none;
outline: none;
}
Just add this to your CSS:
.resetButton:focus {
outline: none;
}
Could also be box-shadow. Try something like:
.resetButton{ box-shadow: none; }
or
resetButton:focus{ box-shadow: none; }
Related
Implemented a clear button using -webkit-search-cancel-button following the next post:
https://stackoverflow.com/a/64267916/1065145
The problem with the implementation referenced above is that it renders the clear icon invisible when out of focus, but it still occupies space and it doesn't look nice at all:
It can be either a long placeholder on a small device or a long user query:
Trying to solve it with display: none doesn't really work, because it still renders invisible when the input is in focus, but there is no user input yet and only the placeholder is shown (and part of it is eaten by the invisible icon).
Q. Is there a way to make icon truly invisible so it is shown only on two conditions:
The input is in focus.
User has provided some input and the placeholder is gone.
display: none; and display: block; worked for me (the newest Chrome).
It it necessary to add dispay block when in focus (input[type="search"]:focus::-webkit-search-cancel-button).
If it still not working, try with !important. Sometimes browser style is harder to override. (I'm not recommending using !important, but sometimes there is no other way).
if you want show clear button even with no tekst provided by user add:
input[type="search"]::-webkit-search-cancel-button {
opacity: 1 !important;
}
input[type="search"] {
border: 1px solid gray;
padding: .2em .4em;
border-radius: .2em;
}
input[type="search"].dark {
background: #222;
color: #fff;
}
input[type="search"].light {
background: #fff;
color: #222;
}
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none;
height: 1em;
width: 1em;
margin-left: .5em;
border-radius: 50em;
background: url(https://pro.fontawesome.com/releases/v5.10.0/svgs/solid/times-circle.svg) no-repeat 50% 50%;
background-size: contain;
display: none;
pointer-events: none;
}
input[type="search"]:focus::-webkit-search-cancel-button {
display: block;
pointer-events: all;
}
input[type="search"].dark::-webkit-search-cancel-button {
filter: invert(1);
}
<input type="search" placeholder="search" class="light">
<input type="search" placeholder="search" class="dark">
Edited:
I manage to do it, like you wanted.
I used: https://developer.mozilla.org/en-US/docs/Web/CSS/:placeholder-shown
I also left outline borders for better understanding.
input[type="search"] {
border: 1px solid gray;
padding: .2em .4em;
border-radius: .2em;
}
input[type="search"].dark {
background: #222;
color: #fff;
}
input[type="search"].light {
background: #fff;
color: #222;
}
input[type="search"]::-webkit-textfield-decoration-container {
width: 100%;
}
/* normal state, with placeholder and no value */
input[type="search"]:placeholder-shown::-webkit-textfield-decoration-container {
outline: 1px dotted yellow;
}
/* focused state, with placeholder and no value */
input[type="search"]:placeholder-shown:focus::-webkit-textfield-decoration-container {
outline: 1px dotted red;
}
/* focused state, with value */
input[type="search"]:not(:placeholder-shown):focus::-webkit-textfield-decoration-container {
outline: 1px dotted green;
}
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none;
height: 1em;
width: 0;
border-radius: 50em;
background: url(https://pro.fontawesome.com/releases/v5.10.0/svgs/solid/times-circle.svg) no-repeat 50% 50%;
background-size: contain;
pointer-events: none;
}
input[type="search"]:not(:placeholder-shown):focus::-webkit-search-cancel-button {
display: block;
width: 1em;
margin-left: .5em;
}
input[type="search"]:focus::-webkit-search-cancel-button {
pointer-events: all;
}
input[type="search"].dark::-webkit-search-cancel-button {
filter: invert(1);
}
<input type="search" placeholder="search search search search search search" class="light">
<input type="search" placeholder="search search search search search search" class="dark">
I have checked you're issue and from my point of view the easiest way to solve the issue is the following:
input[type="search"]::-webkit-search-cancel-button {
display: none;
}
input[type="search"]:focus::-webkit-search-cancel-button {
display: block;
}
You should add those 2 lines to you're existing code and should be fine
:)
Code is here : https://codepen.io/BaciuTudor/pen/YzxaYKV
I have come up against a very annoying CSS issue while trying to get a project working cross-browser (not bothered about IE, it's only a hobby project, but it would be nice to get it working on all modern browsers at the very least). It relates to some checkboxes which I wish to apply custom styles to - I know you can't do very much with the standard HTML <input type="checkbox"> so I have done what is recommended in many places, and used a ::before pseudo-element. And I was pleased with the result in Chrome. Imagine my surprise when I find that my custom checkbox simply doesn't display at all in Firefox!
I've been playing with this for a few hours and have stripped it right back to the very root of the problem - and it's something to do with the checkbox itself, rather than any other CSS it's interacting with. Here's the bare minimum example:
input[type="checkbox"] {
visibility: hidden;
}
input[type="checkbox"]::before {
visibility: visible;
content: "";
display: block;
width: 1.1em;
height: 1.1em;
color: #eddc23;
border: 1px solid #eddc23;
background-color: #540123;
border-radius: 35%;
line-height: 1.27;
text-align: center;
cursor: pointer;
}
input[type="checkbox"]:checked::before {
content: "\2713";
}
<input type="checkbox">
This should show a dark red checkbox which has a yellow tick when selected. It works perfectly on Chrome and Opera, but not at all on Firefox or Edge. (Here's a CodePen link of the same in case the Stack Overflow snippet somehow exhibits different behaviour). CSS isn't one of my strong points and despite a few hours of experimenting and googling, I'm baffled.
Would appreciate any pointers, not only as to how to get this working cross-browser, but as to why it's not working on FF/Edge (inspecting the element on Firefox shows no sign of a ::before pseudo-element at all. I've also ruled out it being to do with the empty content property, since changing that to real text fails to make it visible in the browsers concerned).
Sometimes with labels you can solve this type of problems
input[type="checkbox"] {
display: none;
}
span {
visibility: visible;
content: "";
display: block;
width: 1.1em;
height: 1.1em;
color: #eddc23;
border: 1px solid #eddc23;
background-color: #540123;
border-radius: 35%;
line-height: 1.27;
text-align: center;
cursor: pointer;
}
input[type="checkbox"]:checked + label span::before {
content: "\2713";
}
<input type="checkbox" id="checkbox">
<label for="checkbox">
<span></span>
</label>
Just to record it in brief, what I ended up doing was putting a <div> as the next sibling of the checkbox, hiding the checkbox with opacity: 0;, and positioning the div on top of the checkbox but with lower z-index. This means that the "fake" checkbox responds in the same way a real one would, and by keeping the actual checkbox in the DOM hopefully this would still score reasonably on accessibility.
You should reset the appearance:
input[type=checkbox] {
/* Reset */
-webkit-appearance: none;
appearance: none;
background-color: #fff;
}
But the best way is here: https://moderncss.dev/pure-css-custom-checkbox-style/
Example snippet:
/* Checkboxes */
input[type=checkbox] {
/* Reset */
-webkit-appearance: none;
appearance: none;
background-color: #fff;
width: 0;
height: 0;
margin: 0;
margin-right: 25px;
position: relative;
text-align: center;
font-size: 16px;
}
input[type=checkbox]:focus {
box-shadow: none;
outline: none;
}
input[type=checkbox]::before {
content: '';
position: absolute;
top: -16px;
display: block;
width: 20px;
height: 20px;
border: 1px solid #23151d;
background: #fff;
box-sizing: content-box;
border-radius: 3px;
}
input[type=checkbox]:checked::before {
border: 1px solid #e63244;
background: transparent;
background: #e6324403;
}
input[type=checkbox]::after {
content: '✓';
text-indent: 4px;
position: absolute;
top: -14px;
display: none;
width: 20px;
height: 20px;
box-sizing: content-box;
text-align: center;
}
input[type=checkbox]:checked::after {
display: block;
color: #e63244;
}
/* / Checkboxes */
<p>
<input type="checkbox" checked>
<input type="checkbox" checked>
<input type="checkbox" checked>
</p>
I have a problem that I believe might be pretty stupid, but I can't figure out.
I have a form, where I want to align the elements in both sides, problem is I can't align it to the right (where the red line is), here is a picture to show it:
and here is my SASS (sorry if is not very tidy I been working for a while in it and might be messy):
.contact {
margin: 100px auto 0;
max-width: $half-width;
form {
letter-spacing: 2px;
color: $color4;
input, textarea {
border: 3px solid $color5;
padding: 10px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
font-size: 16px;
background: $color6;
&:focus {
outline: none !important;
border-color: $color3 !important;
}
textarea {
height: 10em;
width: 100%;
overflow: inherit;
}
}
.info-group {
margin-top: 10px;
label {
display: inline-block;
width: 45%;
float: left;
&:nth-child(2) {
float: right !important;
margin: 0 auto;
}
}
}
.tell-group {
width: 100%;
label {
display: inline-block;
margin-top: 10px;
}
textarea {
height: 10em;
width: 100%;
float: left;
}
}
.submit-wrap {
margin-top: 10px;
float: right;
input {
width: 100px;
font-size: 18px;
text-transform: uppercase;
color: $color6;
background-color: $color5;
border: none;
&:hover {
color: $color1;
}
}
}
}
}
Thanks!
padding: 10px; is going to add 20px to the width, this extra width is likely what is causing the problem. You can change the width attribute to width: calc(100% - 20px); to account for the 10px padding on each side of the element.
Here is a list of where calc is supported: http://caniuse.com/#feat=calc
You can also try adding these css rules to the problem elements to move them over:
position: relative;
left: -20px;
You might also have to add position: relative; to the parent element
Here is a fiddle showing the left -20px method: http://jsfiddle.net/0f153w8e/
Side note: you might have to adjust the left amount a little bit to make it exact if your text areas have borders (which they probably do)
I am styling a checkbox to keep the user signed in, but I have ran into a problem that occurs within Firefox and IE. The checkbox looks like the following in all other browsers:
In other IE and Firefox, the checkbox looks like this:
My code is as follows:
<label id="checkbox">
<input type="checkbox" name="signinForm_keepSignedIn" id="signinForm_keepSignedIn" checked>
<span id="checkbox_span"></span>
</label>
<style>
#checkbox {
position: absolute;
left: 0px;
margin-left: 30px;
margin-top: 185px;
width: 110px;
height: 16px;
}
#signinForm_keepSignedIn {
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
appearance: none;
position: absolute;
border: none;
background-color: transparent;
}
#checkbox_span {
position: absolute;
width: 16px;
height: 16px;
display: block;
background: url("resources/images/elementBackgrounds/checkbox_unchecked.png");
cursor: pointer;
}
#signinForm_keepSignedIn:checked + #checkbox_span {
background: url("resources/images/elementBackgrounds/checkbox_checked.png");
}
</style>
If know that there is an issue with the initial "hidden" checkbox's appearance, but I don't know how to resolve the issue. What can I do to fix it?
You can add visibility: hidden property to checkbox input:
#checkbox input[type=checkbox] {
visibility: hidden;
}
a question about a drop-down select, which looks not totally correct in its appearance, the default part on the right should not be visible with this code, but it is shown. this is the code, created inside a site developed with bootstrap for mobile template.
do i miss something? do you need more information?
.menuSelect {
-webkit-appearance: none;
appearance: none;
-moz-appearance: none;
height: 75px;
font-size: 30px;
width: 100%;
border: none;
padding: 0 10px;
background: url("img/selectmenu-arrowwhite.png") no-repeat scroll right center #00AEEF;
color: #FFFFFF;
}
thanks in advance
A combination of low indent and text-overflow: '' works on FireFox. I did use it recently as well.
http://jsfiddle.net/Jg2nF/3/
.menuSelect {
-webkit-appearance: none;
appearance: none;
-moz-appearance: none;
height: 75px;
font-size: 30px;
width: 100%;
border: none;
padding: 0 10px;
background: url("img/selectmenu-arrowwhite.png") no-repeat scroll right center #00AEEF;
color: #FFFFFF;
}
I forgot IE, sorry. I'm using this currently:
http://jsfiddle.net/Jg2nF/4/
select::-ms-expand {
display: none;
}