I have this very strange issue in Safari, both desktop and iOS. Here is a screenshot of what is currently happening (again, both iOS and desktop Safari):
And here is a picture of what should be happening (taken from Chrome on Mac, but also confirmed the same in Android Chrome and Firefox):
Here is the HTML:
<label class="radio-selections" for="maleSelection">Male
<input type="radio" value="male" id="maleSelection" name="gender">
</label>
And here is the CSS:
label.radio-selections {
width: 95%;
max-width: 400px;
height: 55px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: var(--dark-gray);
transition: box-shadow 100ms;
border-radius: 6px;
input[type=radio] {
apperance: none;
-webkit-appearance: none;
height: inherit;
width: inherit;
max-width: inherit;
position: absolute;
border-radius: 6px;
z-index: -1;
background-color: transparent;
cursor: pointer;
}
&[for=femaleSelection] {
box-shadow: 0 1px 7px 3px rgba(147,64,169,.65);
&:active {
box-shadow: 0 1px 7px 1px rgba(147,64,169,.35);
}
input[type=radio]:checked {
background-color: rgba(147,64,169,.15)
}
}
&[for=maleSelection] {
box-shadow: 0 1px 7px 3px rgba(64,93,169,.65);
&:active {
box-shadow: 0 1px 7px 1px rgba(64,93,169,.35);
}
input[type=radio]:checked {
background-color: rgba(64,93,169,.15)
}
}
}
I think it could be well understood what I'm lacking here, but why is the "checked" styling in iOS and Safari offset, while in all other browsers it is overlapping as it should?
Here is also a pretty simple codepen that pretty much outlines what I'm looking for (obviously works in Chrome, but not in Safari):
https://codepen.io/adammcgurk/pen/wvvJWry
Use position: relative; on parent when ever you make any element absolute so that it adjust itself according to its parent.
label.radio-selections {
position: relative;
}
and then on child make left right top and bottom to 0
input[type=radio] {
left: 0;
right: 0;
bottom: 0;
top: 0;
}
Related
Per the code snippet below, I am trying to create a tool tray with vertical sliders, styled like procreates ui.
When I rotate the tray 90 degrees using transforms to get everything vertical, the sliders break on mobile (any touch device), I can click them to position but pressing and sliding breaks. If I remove the rotate class, all works fine.
Tested on a wacom touch screen monitor, ipad pro and samsung z fold 3, all touch devices the slider is broken on though works as expected with mouse. Pen devices seem to also break, unable to move the sliders smoothly.
Any help fixing this or a better approach would be greatly welcome, trying to get this to work without javascript
/* Desperate to remove focus outline in firefox */
::-moz-focus-inner {
outline:0;
}
:focus {
outline:0;
}
.topcoat-range-input--vertical {
position: relative;
/*padding: 0;
margin: 0;*/
border: none;
box-sizing: border-box;
background-clip: padding-box;
vertical-align: top;
outline: none;
-webkit-appearance: none;
border-radius: 4px;
border: 1px solid #a5a8a8;
background: #CCd3d7d7;
height: 2rem;
border-radius: 4px;
}
.topcoat-range-input--vertical::-webkit-slider-thumb{
cursor: pointer;
-webkit-appearance: none;
}
.topcoat-range-input--vertical::-moz-range-thumb {
cursor: pointer;
}
/*.topcoat-range-input--vertical {
border-radius: 4px;
border: 1px solid #a5a8a8;
background: #d3d7d7;
height: 2rem;
border-radius: 4px;
}*/
.topcoat-range-input--vertical::-webkit-slider-thumb {
height: 2rem;
width: 1.2rem;
border: 1px solid rgba(0,0,0,0.36);
border-radius: 6px;
background: #e5e9e8;
background-size: 7px 18px;
box-shadow: inset 0 1px white;
}
.topcoat-range-input--vertical::-moz-range-thumb {
height: 2rem;
width: 1.2rem;
border: 1px solid rgba(0,0,0,0.36);
border-radius: 6px;
background: #e5e9e8;
background-size: 7px 18px;
box-shadow: inset 0 1px white;
}
::-ms-tooltip,
::-ms-fill-lower {
display: none;
}
.topcoat-range-input--vertical {
/*display: block;
box-sizing: border-box;*/
vertical-align: middle;
}
#tool-setting-palette{
background: #000000;
opacity: 0.8;
height: fit-content;
width: fit-content;
padding: .3em;
border-radius: 0.5em;
position: fixed;
left: 2em;
bottom: 0;
}
.btn {
background-color: transparent;
width: 1.5em;
height: 1.5em;
border: none;
color: white;
font-size: 1.2em;
cursor: pointer;
vertical-align: middle;
}
/* Darker background on mouse-over */
.btn:hover {
color: RoyalBlue;
}
.btn:active {
color: Blue;
transform-origin: center;
transform:scale(0.9);
}
.rotate-rev-90{
transform-origin: center left;
-webkit-transform:rotate(-90deg);
-moz-transform:rotate(-90deg);
-ms-transform:rotate(-90deg);
transform:rotate(-90deg);
}
.rotate-90, .rotate-90 .btn:hover, .rotate-90 .btn:active{
transform-origin: center;
-webkit-transform:rotate(90deg);
-moz-transform:rotate(90deg);
-ms-transform:rotate(90deg);
transform:rotate(90deg);
}
<div id="tool-setting-palette" class="rotate-rev-90">
<button id="redo-btn" type="button" value="" class="btn rotate-90"><i class="fa fa-repeat"></i></button>
<button id="undo-btn" type="button" value="" class="btn rotate-90"><i class="fa fa-undo"></i></button>
<input type='range' class='topcoat-range-input--vertical'>
<input type='range' class='topcoat-range-input--vertical'>
</div>
https://codepen.io/taibhse-designs/pen/zYLxvOj
Smiley Face
Im working on a customer survey page and this is currently what i have. Those are images as radio buttons. The problem is when it's checked, it's ugly with the red square outline. Is there a way to make it circular soft glow? This is the code. I've search up the outline style but they're mostly dotted or double lines style and that's not what im looking for. Any help is appreciated.
<label style="display: inline-block;">
<h3>Dissatisfied</h3>
<input type="radio" ngModel name="smiley" value="Dissatisfied">
<img src="..\assets\images\smiley_2_62x62.png">
</label>
Full css for the radio and form.
[type=radio] {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
/* IMAGE STYLES */
[type=radio] + img {
cursor: pointer;
}
/ * CHECKED STYLES */
[type=radio]:checked + img {
outline: 2px solid #f00;
}
This will change the border to be round like the image and give it a glow:
[type=radio]:checked + img {
outline: 2px solid #f00;
border-radius: 32px;
overflow: hidden;
box-shadow: 0 0 5px 5px #f00;
}
I would use the following:
/ * CHECKED STYLES */
[type=radio]:checked + img {
border: 2px solid #f00;
border-radius: 50%
}
You should use borders for the rounded effect instead of outline. Set the border-radius for the image.
[type=radio]+img {
cursor: pointer;
height: 50px;
width: 50px;
}
[type=radio]:checked + img {
border: 2px solid #9ecaed;
border-radius: 50px;
box-shadow: 0 0 10px #9ecaed;
}
I would also recommend you to use javascript to toggle the radio button on click or you could just make the radio button the same size as your image. Of course the non-javascript way would be easier.
There are many ways to change the look of the native input element UI, use the below code to change the look of radio buttons.
.check_radio {
margin:15px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
cursor: pointer;
font-family: "Lato";
font-size: 14px;
color: #231E1E;
font-weight: 500;
line-height: 1.4;
}
.check_radio input[type="radio"] {
position: absolute;
opacity: 0;
}
.check_radio input[type="radio"] + span {
margin: 0 5px 0 0;
display: block;
height: 20px;
width: 20px;
background: #FFFFFF;
border: 1px solid #6E6B6B;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-radius: 50%;
-webkit-box-shadow: 0px 4px 8px rgb(44 39 56 / 8%);
box-shadow: 0px 4px 8px rgb(44 39 56 / 8%);
position: relative;
}
.check_radio input[type="radio"]:checked + span {
border: 2px solid #2474FF;
}
.check_radio input[type="radio"]:checked + span:after {
content: '';
background: #2474FF;
width: 10px;
height: 10px;
position: absolute;
border-radius: 50%;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
<label for="rm_1" class="check_radio">
<input type="radio" name="payment_type" id="rm_1">
<span></span>
Full Payment
</label>
<label for="rm_2" class="check_radio">
<input type="radio" name="payment_type" id="rm_2">
<span></span>
Partial Payment
</label>
I've spent hours looking at similar problems and nothing I try changes the fill color for the selected range in Chrome. Changing color in -webkit-progress-value and -webkit-progress-bar does nothing. I've also tried some Vanilla JS as well, but that didn't work either.
I might have looked myself blind on this problem. What am I missing?
PS. I'm not able to get my code working here at Stack (sorry), but I have a working example in Code Pen
input[type="range"] {
margin: 0;
padding: 0;
border: 0;
outline: none;
background: transparent;
width: 100%;
height: 22px;
border-radius: 3px;
-webkit-appearance: none; // Chrome reset
}
input[type="range"]::-webkit-slider-runnable-track {
height: 3px;
border-radius: 2px;
background-color: #434b52;
transition: all .2s ease;
}
input[type="range"]::-webkit-progress-value {
background-color: #ff0000; // red
}
input[type="range"]::-webkit-progress-bar {
background-color: #00ff00; // Green
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none; // Chrome reset
box-sizing: border-box;
height: 16px;
width: 16px;
border-radius: 50%;
border: solid 2px #2bdeee;
background-color: #25bbc8;
cursor: pointer;
margin-top: -7px;
}
.kx-range {
padding: 4px 8px;
}
html {
background-color: #262a2f;
margin-top: 50px;
}
<div class="kx-range">
<input id="ranger" type="range" min="0" max="1000" value="250" step="1">
</div>
I am implementing a search box for a html-javascript based app using Chrome:
fiddle
it should look like this:
but when I deploy app on iphone,
screen looks like this:
I know it's difference with webkit, I thought using safari to debug it would be a solution, however,when I use safari to open it, it looks like this:
Just don't know why on iPhone, it looks like that. How to improve it to the feature which I need?
Here is the html:
<div class="form-wrapper">
<input type="text" placeholder="Search here..." required>
<button type="submit">Search</button>
</div>
CSS:
.form-wrapper {
height: 80px;
background: #555;
color: #FFF;
clear: both;
}
.form-wrapper input {
background-color: #FFF;
-moz-box-sizing: border-box;
border-radius: 10px;
border: 5px solid #E5E4E2;
margin: 2px;
height: 40px;
vertical-align: middle;
padding: 20px;
margin-top: 15px;
width: 85%;
}
.form-wrapper button {
overflow: visible;
position: absolute;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 40px;
width: 110px;
color: #FFF;
text-transform: uppercase;
background: red;
border-radius: 0 3px 3px 0;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
margin: 20px -116px;
}
.form-wrapper button:before {
content:'';
position: absolute;
border-width: 8px 8px 8px 0;
border-style: solid solid solid none;
border-color: transparent red transparent;
top: 12px;
left: -6px;
}
type="search" causes the field to have a -webkit-appearance: searchfield on Safari, which causes lots of your styles to be ignored.
Have either a none appearance or textfield appearance.
Here is a fiddle with none, which seems to work for me on Safari 6/OSX (no iDevice available to test).
On opera, i can do the following
<style>
#range{
width: 20px;
heigth: 300px;
}
</style>
<input type="range" id="range" />
and it will render a vertical slider. However, this doesn't seem to work on chrome. Is there a way I can do this? (I'm not looking for any jQuery sliders or anything)
It seems Chromium does not yet implement support for this yet:
See: http://www.chromium.org/developers/web-platform-status/forms
Not available yet
Localization of
Dedicated UIs for color, date, datetime, datetime-local, month, time,
and week types
Automatic switching to vertical range
Value sanitization algorithms
datalist element, list attribute, and list/selectedOption properties
Edit: Vuurwerk indicated that it is actually possible to alter the presentation using the -webkit-appearance: slider-vertical property. Although this does transform it into a vertical slider, I would not recommend doing this, since it will break your layout and doesn't look really pretty: example.
If you really want a vertical slider, use a JavaScript solution. Support for <input type="range" /> is very basic at the moment anyway, so you are probably better off with a graceful degradation or progressive enhancement approach.
-webkit-appearance: slider-vertical;
Maybe with a css transform ?
-webkit-transform: rotate(90);
Another solution could be to use the slider module from jQuery UI.
http://jqueryui.com/demos/slider/#slider-vertical
input[type='range']{
width:20px;
height:140px;
border:2px solid blue;
display:block;
-webkit-transform:rotate(90deg); /* Safari and Chrome */
-moz-transform:rotate(90deg);
-o-transform:rotate(90deg);
-ms-transform:rotate(90deg);
transform:rotate(90deg);
z-index: 0;
}
As Aron has said there is no support for webkit browser.
However this is what i could do for achieving the output.
body {
margin: 50px;
}
.opacitySlider {
position: relative;
transform: rotate(90deg);
width: 125px;
height: 20px;
}
.opacitySlider:before {
content: " ";
left: 10px;
top: 1px;
position: absolute;
border-top: 9px solid transparent;
border-bottom: 9px solid transparent;
border-left: 115px solid #ccc;
}
.opacitySlider input[type=range] {
outline: none;
-webkit-appearance: none;
height: 20px;
padding: 0;
width: 125px;
background: transparent;
position: relative;
margin: 0;
cursor: pointer;
}
.opacitySlider input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
background: #69a80e;
height: 20px;
width: 20px;
border: 1px solid #fff;
border-radius: 50%;
}
.opacitySlider input[type=range]::-moz-range-track {
border: none;
background-color: transparent;
}
.opacitySlider input[type=range]::-moz-range-thumb {
background: #69a80e;
height: 20px;
width: 20px;
border: 1px solid #fff;
border-radius: 50%;
}
.opacitySlider input[type=range]::-ms-fill-lower, .opacitySlider input[type=range]::-ms-fill-upper {
background: transparent;
}
.opacitySlider input[type=range]::-ms-track {
height: 18px;
border: none;
background-color: transparent;
margin: 0;
}
.opacitySlider input[type=range]::-ms-thumb {
background: #69a80e;
height: 20px;
width: 20px;
border: 1px solid #fff;
border-radius: 50%;
height: 17px;
width: 17px;
}
<div class="opacitySlider">
<input step="any" type="range">
</div>