I'm trying to "fill" a circle when a user clicks on it. The main issue is that when the animation ends, it's offset on the top by just a little bit. I've tried to add a margin-top: -1px to it but it's then offset on the bottom!
I'm open to any suggestion to make the animation smoother but my main question is: Why is the end result offset from the top a tiny bit and how can I fix it?
#searchOptions label {
display: inline-block;
cursor: pointer;
font-size: 14px;
text-transform: uppercase;
color: #000;
font-weight: 400;
margin-right: 40px;
}
#searchOptions label .circle {
display: inline-block;
position: relative;
border: 2px solid #000;
width: 15px;
height: 15px;
border-radius: 50%;
margin-right: 12px;
}
#searchOptions label .circle:before {
display: none;
position: absolute;
content: '';
background-color: #000;
border-radius: 50%;
top: 50%;
transform: translateY(-50%);
left: 0;
right: 0;
margin: 0 auto;
width: 2px;
height: 2px;
}
#searchOptions label .txt {
position: relative;
top: -3px;
}
#searchOptions input[type=radio] {
height: 0;
width: 0;
opacity: 0;
}
#searchOptions input[type=radio]:checked + label .circle:before {
display: block;
width: 100%;
height: 100%;
animation: fillRadio ease-in 1s;
}
#-webkit-keyframes fillRadio {
0% {
top: 50%;
transform: translateY(-50%);
width: 1%;
height: 1%;
}
100% {
top: 0%;
transform: translateY(0%);
width: 100%;
height: 100%;
}
}
<div id="searchOptions">
<input type="radio" name="searchType" value="option1" id="option1" />
<label for="option1"><span class="circle"></span> <span class="txt">Option 1</span>
</label>
<input type="radio" name="searchType" value="option2" id="option2" />
<label for="option2"><span class="circle"></span> <span class="txt">Option 2</span>
</label>
</div>
<!-- id="searchOptions" -->
Here's a JSFiddle if anyone would rather use that.
I believe that the problem comes from a dimensiion of 15px and top of 50% -> that gives a fractional size
I have changed the size to 16px, that is even:
#searchOptions label {
display: inline-block;
cursor: pointer;
font-size: 14px;
text-transform: uppercase;
color: #000;
font-weight: 400;
margin-right: 40px;
}
#searchOptions label .circle {
display: inline-block;
position: relative;
border: 2px solid #000;
width: 16px;
height: 16px;
border-radius: 50%;
margin-right: 12px;
}
#searchOptions label .circle:before {
display: none;
position: absolute;
content: '';
background-color: #000;
border-radius: 50%;
top: 50%;
transform: translateY(-50%);
left: 0;
right: 0;
margin: 0 auto;
width: 2px;
height: 2px;
}
#searchOptions label .txt {
position: relative;
top: -3px;
}
#searchOptions input[type=radio] {
height: 0;
width: 0;
opacity: 0;
}
#searchOptions input[type=radio]:checked + label .circle:before {
display: block;
width: 100%;
height: 100%;
animation: fillRadio ease-in 1s;
}
#-webkit-keyframes fillRadio {
0% {
top: 50%;
transform: translateY(-50%);
width: 1%;
height: 1%;
}
100% {
top: 0%;
transform: translateY(0%);
width: 100%;
height: 100%;
}
}
<div id="searchOptions">
<input type="radio" name="searchType" value="option1" id="option1" />
<label for="option1"><span class="circle"></span> <span class="txt">Option 1</span>
</label>
<input type="radio" name="searchType" value="option2" id="option2" />
<label for="option2"><span class="circle"></span> <span class="txt">Option 2</span>
</label>
</div>
<!-- id="searchOptions" -->
Related
I am trying to add arrows on the left and right side of the slider but even though the arrows Z-index is lower than the navigations Z-index, the surface above the arrows is not clickable.
Everything else works, but you can't have an image slider where the arrows are not clickable even though the surroundings of it is.
Please I have tried everything, my mind could come up with. Do you have any idea what could cause this problem? And how to fix it?
body {
margin: 0;
}
#container {
width: 960px;
height: 740px;
position: relative;
margin: 0px;
}
#container input {
display: none;
}
.images {
width: 100%;
height: 100%;
position: absolute;
}
.images img {
width: 100%;
height: 100%;
margin: 0px;
}
.prev,
.next {
height: 100%;
width: 12%;
position: absolute;
top: 0;
transition: .15s;
z-index: 100;
margin: 0px;
}
.prev:hover,
.next:hover {
cursor: pointer;
/* background: rgba(10, 10, 10, .5);*/
}
.prev {
left: 0
}
.next {
right: 0
}
#nav {
width: 100%;
height: 35px;
position: absolute;
bottom: 0px;
text-align: center;
cursor: arrow;
z-index: 100;
}
.dots {
width: 12px;
height: 12px;
margin: 0 4px;
border-radius: 50%;
background: rgba(10, 10, 10, .7);
position: relative;
display: inline-block;
cursor: pointer;
}
.dots:hover {
*background: rgba(245, 245, 245, .7);
}
#one,
#two,
#three {
z-index: -1;
}
#inp1:checked~#one,
#inp2:checked~#two,
#inp9:checked~#three {
z-index: 10;
}
#inp1:checked~#nav #dot1,
#inp2:checked~#nav #dot2,
#inp9:checked~#nav #dot3 {
background: white;
opacity: 70%;
}
.arrow:hover {
cursor: pointer;
}
.arrow {
border: solid white;
border-width: 0 6px 6px 0;
display: inline-block;
padding: 10px;
color: white;
opacity: 70%;
margin: 0px;
z-index: 11;
left: 0;
right: 0;
}
.right {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
position: relative;
left: 900px;
top: 400px;
}
.left {
transform: rotate(135deg);
position: relative;
top: 400px;
right: 0px;
}
<div id='container'>
<input type='radio' name="image" id='inp1' checked>
<input type='radio' name="image" id='inp2'>
<input type='radio' name="image" id='inp3'>
<i class="arrow right"></i>
<i class="arrow left"></i>
<div class='images' id='one'>
<img src='img/image1.jpeg'>
<label for='inp3' class='prev'></label>
<label for='inp2' class='next'></label>
</div>
<div class='images' id='two'>
<img src='img/image2.jpeg'>
<label for='inp1' class='prev'></label>
<label for='inp3' class='next'></label>
</div>
<div class='images' id='three'>
<img src='img/image3.jpeg'>
<label for='inp2' class='prev'></label>
<label for='inp1' class='next'></label>
</div>
<div id='nav'>
<label class='dots' id='dot1' for='inp1'></label>
<label class='dots' id='dot2' for='inp2'></label>
<label class='dots' id='dot3' for='inp3'></label>
</div>
</div>
I've made custom checkbox, here is what i've made so far, but what I need is something like this, where there is also text and one image (not icon/fa-fa icon) in the center of the checkbox. Did u know how to achieve it? Here is the code from snippet:
div {
display: inline-block;
}
input[type="checkbox"][id^="cb"] {
display: none;
}
label {
display: block;
position: relative;
cursor: pointer;
height: 120px;
outline: 1px solid white;
width: 120px;
}
label:before {
background-color: red;
color: white;
display: block;
position: absolute;
width: 20px;
height: 20px;
top: 1px;
left: 1px;
text-align: center;
line-height: 20px;
transition-duration: 0.4s;
-webkit-transition-duration: 0.4s;
-moz-transition-duration: 0.4s;
-ms-transition-duration: 0.4s;
}
label img {
height: 100%;
width: 100%;
}
:checked + label {
border-color: red;
}
:checked + label:before {
content: "✓";
background-color: red;
outline: 1px solid red;
z-index: 99;
}
:checked + label img {
z-index: -1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
height: 95%;
width: 95%;
outline: 3px solid red;
}
<div>
<div>
<input type="checkbox" id="cb1" />
<label for="cb1"><img src="http://lorempixel.com/103/103" /></label>
</div>
<div>
<input type="checkbox" id="cb2" />
<label for="cb2"><img src="http://lorempixel.com/102/102" /></label>
</div>
</div>
Thanks in advance for your help.
You're doing just fine at your own. Your code looks a bit complex because you can use the label as a block-element (like a div or a wrapper). Take a step back, look at your layout 'inside' the checkbox and see it as a normal layout/styling element. Nothing fancy.
.styled {
/* could also be a background */
background-color: red;
padding: 1rem 4rem;
text-align: center;
cursor: pointer;
}
span {
display: block;
font-size: 16px;
font-family: Arial;
margin-top: 10px;
}
label {
display: block;
max-width: 100px;
margin: 0 auto;
}
#checkbox {
display: none;
}
input:checked+label {
background-color: green;
}
<input id="checkbox" type="checkbox">
<label class="styled" for="checkbox">
<img src="https://placehold.it/20x20" alt="image 1">
<img src="https://placehold.it/40x40" alt="image 2">
<img src="https://placehold.it/60x60" alt="image 3">
<span>Text</span>
</label>
<div>
<div><input type="checkbox" id="cb1" />
<label for="cb1">
<img src="http://lorempixel.com/103/103" />
<img src="https://dummyimage.com/120/000000/ffffff" />
<span>Text</span>
</label>
</div>
<div><input type="checkbox" id="cb2" />
<label for="cb2">
<img src="http://lorempixel.com/102/102" />
<img src="https://dummyimage.com/120/000000/ffffff" />
<span>Text</span>
</label>
</div>
</div>
div {
display: inline-block;
}
input[type="checkbox"][id^="cb"] {
display: none;
}
label {
display: block;
position: relative;
cursor: pointer;
height: 120px;
outline: 1px solid white;
width: 120px;
}
label:before {
background-color: red;
color: white;
display: block;
position: absolute;
width: 20px;
height: 20px;
top: 1px;
left: 1px;
text-align: center;
line-height: 20px;
transition-duration: 0.4s;
}
label img {
height: 100%;
width: 100%;
z-index: 1;
}
label img + img {
height: 60%;
width: 60%;
z-index: 2;
position: absolute;
top: 10%;
left: 20%;
}
span {
z-index: 2;
color: red;
position: absolute;
top: 75%;
left: 40%;
text-align: center;
}
:checked + label {
border-color: red;
}
:checked + label:before {
content: "✓";
background-color: red;
outline: 1px solid red;
z-index: 3;
}
:checked + label img + img {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
height: 60%;
width: 60%;
outline: 0px solid transparent;
}
:checked + label img {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 98%;
width: 98%;
outline: 3px solid red;
}
I want to make this example to work. I need it on my project but i don't understand CSS and can't seem to figure out why this isn't working. Any help would be appreciated.
Why is this example working on codepen : codepen link
But is not working in jsfiddle or my website : Jsfiddle link
Code(CSS):
.inputGroup {
background-color: #fff;
display: block;
margin: 10px 0;
position: relative;
label {
padding: 12px 30px;
width: 100%;
display: block;
text-align: left;
color: #3C454C;
cursor: pointer;
position: relative;
z-index: 2;
transition: color 200ms ease-in;
overflow: hidden;
&:before {
width: 10px;
height: 10px;
border-radius: 50%;
content: '';
background-color: #5562eb;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) scale3d(1, 1, 1);
transition: all 300ms cubic-bezier(0.4, 0.0, 0.2, 1);
opacity: 0;
z-index: -1;
}
&:after {
width: 32px;
height: 32px;
content: '';
border: 2px solid #D1D7DC;
background-color: #fff;
background-image: url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.414 11L4 12.414l5.414 5.414L20.828 6.414 19.414 5l-10 10z' fill='%23fff' fill-rule='nonzero'/%3E%3C/svg%3E ");
background-repeat: no-repeat;
background-position: 2px 3px;
border-radius: 50%;
z-index: 2;
position: absolute;
right: 30px;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
transition: all 200ms ease-in;
}
}
input:checked ~ label {
color: #fff;
&:before {
transform: translate(-50%, -50%) scale3d(56, 56, 1);
opacity: 1;
}
&:after {
background-color: #54E0C7;
border-color: #54E0C7;
}
}
input {
width: 32px;
height: 32px;
order: 1;
z-index: 2;
position: absolute;
right: 30px;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
visibility: hidden;
}
}
// codepen formatting
.form {
padding: 0 16px;
max-width: 550px;
margin: 50px auto;
font-size: 18px;
font-weight: 600;
line-height: 36px;
}
body {
background-color: #D1D7DC;
font-family: 'Fira Sans', sans-serif;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
code {
background-color: #9AA3AC;
padding: 0 8px;
}
Here is the Html code :
<form class="form">
<h2>Checkboxes</h2>
<div class="inputGroup">
<input id="option1" name="option1" type="checkbox"/>
<label for="option1">Option One</label>
</div>
<div class="inputGroup">
<input id="option2" name="option2" type="checkbox"/>
<label for="option2">Option Two</label>
</div>
<h2>Radio Buttons</h2>
<div class="inputGroup">
<input id="radio1" name="radio" type="radio"/>
<label for="radio1">Yes</label>
</div>
<div class="inputGroup">
<input id="radio2" name="radio" type="radio"/>
<label for="radio2">No</label>
</div>
</form>
Because you are not using compiled css.
See below snippet
.inputGroup {
background-color: #fff;
display: block;
margin: 10px 0;
position: relative;
}
.inputGroup label {
padding: 12px 30px;
width: 100%;
display: block;
text-align: left;
color: #3C454C;
cursor: pointer;
position: relative;
z-index: 2;
transition: color 200ms ease-in;
overflow: hidden;
}
.inputGroup label:before {
width: 10px;
height: 10px;
border-radius: 50%;
content: '';
background-color: #5562eb;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%) scale3d(1, 1, 1);
transform: translate(-50%, -50%) scale3d(1, 1, 1);
transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
opacity: 0;
z-index: -1;
}
.inputGroup label:after {
width: 32px;
height: 32px;
content: '';
border: 2px solid #D1D7DC;
background-color: #fff;
background-image: url("data:image/svg+xml,%3Csvg width='32' height='32' viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.414 11L4 12.414l5.414 5.414L20.828 6.414 19.414 5l-10 10z' fill='%23fff' fill-rule='nonzero'/%3E%3C/svg%3E ");
background-repeat: no-repeat;
background-position: 2px 3px;
border-radius: 50%;
z-index: 2;
position: absolute;
right: 30px;
top: 50%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
cursor: pointer;
transition: all 200ms ease-in;
}
.inputGroup input:checked ~ label {
color: #fff;
}
.inputGroup input:checked ~ label:before {
-webkit-transform: translate(-50%, -50%) scale3d(56, 56, 1);
transform: translate(-50%, -50%) scale3d(56, 56, 1);
opacity: 1;
}
.inputGroup input:checked ~ label:after {
background-color: #54E0C7;
border-color: #54E0C7;
}
.inputGroup input {
width: 32px;
height: 32px;
order: 1;
z-index: 2;
position: absolute;
right: 30px;
top: 50%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
cursor: pointer;
visibility: hidden;
}
.form {
padding: 0 16px;
max-width: 550px;
margin: 50px auto;
font-size: 18px;
font-weight: 600;
line-height: 36px;
}
body {
background-color: #D1D7DC;
font-family: 'Fira Sans', sans-serif;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
code {
background-color: #9AA3AC;
padding: 0 8px;
}
<form class="form">
<h2>Checkboxes</h2>
<div class="inputGroup">
<input id="option1" name="option1" type="checkbox"/>
<label for="option1">Option One</label>
</div>
<div class="inputGroup">
<input id="option2" name="option2" type="checkbox"/>
<label for="option2">Option Two</label>
</div>
<h2>Radio Buttons</h2>
<div class="inputGroup">
<input id="radio1" name="radio" type="radio"/>
<label for="radio1">Yes</label>
</div>
<div class="inputGroup">
<input id="radio2" name="radio" type="radio"/>
<label for="radio2">No</label>
</div>
</form>
<link href="https://fonts.googleapis.com/css?family=Fira+Sans" rel="stylesheet">
For some reason my toggle button styles are not working in IE11. The input button should be a green circle but it's showing as a square box with a quite background and black border in IE11:
Here is how it is intended to look:
My code:
.toggle-field {
position: relative;
padding-top: 0.35rem;
}
.toggle-field .Toggle {
padding-left: 75px;
}
.toggle-field .toggle-element {
position: absolute;
top: 0;
left: 0;
width: 68px;
height: 34px;
border-radius: 18px;
border: 2px solid #ccc;
}
.toggle-field input {
appearance: none;
display: block;
position: absolute;
left: 4px;
top: 4px;
width: 26px;
height: 26px;
background: #ccc;
border-radius: 15px;
transition: left 117ms ease;
border: none;
}
.toggle-field input:focus + .toggle-element {
border-color: #aaa;
}
.toggle-field b {
position: absolute;
font-weight: normal;
line-height: 34px;
top: 1px;
left: 40px;
font-size: 0.65rem;
}
.toggle-field .Toggle.On input {
left: 38px;
background: #2ea664;
}
.toggle-field .Toggle.On b {
left: 12px;
}
<div class="field toggle-field null">
<label for="button1" class="Toggle On">
<input type="checkbox" id="button1" name="button1" value="on">
<span class="toggle-element"></span>
<b>YES</b> Question goes here
</label>
</div>
Most of what I have read says that I need to have a certain compatibility tag included, which I have:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Not sure what else to do. Has anyone else had this issue before?
I found a different way of doing this that works in IE11.
.toggle-field {
position: relative;
padding-top: 0.35rem;
}
.toggle-field .Toggle {
padding-left: 80px;
}
.toggle-field input {
appearance: none;
display: block;
position: absolute;
left: 6px;
top: 4px;
width: 26px;
height: 26px;
background: #ccc;
border-radius: 15px;
transition: left 117ms ease;
border: none;
}
.toggle-field .toggle-element {
background-color: #fff;
border: 2px solid #ccc;
bottom: 0;
cursor: pointer;
left: 0;
position: absolute;
right: 0;
top: 0;
transition: .4s;
width: 68px;
height: 32px;
}
.toggle-element:before {
background-color: #ccc;
bottom: 3px;
content: "";
height: 26px;
left: 4px;
position: absolute;
transition: .4s;
width: 26px;
}
input:checked + .toggle-element {
background-color: #fff;
}
input:checked + .toggle-element:before {
transform: translateX(34px);
background-color: #2ea664;
}
.toggle-element {
border-radius: 34px;
}
.toggle-element:before {
border-radius: 50%;
}
<div class="field toggle-field null">
<label for="checkbox" class="Toggle On">
<input type="checkbox" id="checkbox" />
<span class="toggle-element"></span>
</label>
</div>
So using HTML, CSS and Bootstrap, i have 4 icons on the left side of the wrapper, where they are organize similar to a square. But when i resize the window, those icons collapse behind a console that i have below. How can i prevent this from happening(would be nice to keep the buttons in the same position)?
Here's the code for the CSS and the HTML
#designContainer {
display: none;
background-color: #fff;
position: absolute;
bottom: 40px;
top: 120px;
left: 10%;
/*width of toolbar*/
margin-left: 38px;
/*margin of toolbar*/
right: 20px;
overflow: hidden;
border: 1px solid #003399;
/* border-top:3px solid #FFCC00; */
z-index: 10;
cursor: crosshair;
}
#toolsWrapper {
display: none;
background-color: #fff;
position: absolute;
bottom: 40px;
top: 120px;
left: 20px;
width: 10%;
overflow: hidden;
z-index: 11;
margin-bottom: 0;
}
#toolsWrapper label img {
position: relative;
width: 30px;
height: auto;
margin: 10px 0px;
opacity: 0.3;
transition: 0.2s;
}
#toolsWrapper [type=radio] {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
/* IMAGE STYLES */
#toolsWrapper [type=radio]+img {
cursor: pointer;
}
/* CHECKED STYLES */
#toolsWrapper [type=radio]:checked+img {
opacity: 1;
}
#toolsWrapper [type=radio]:checked+img:hover {
opacity: 1;
}
#toolsWrapper [type=radio]+img:hover {
opacity: 0.7;
}
#sideToolButtons {
margin-bottom: 20px;
}
#sideToolButtons button {
outline: none;
width: 20px;
height: auto;
margin: 0;
padding: 0;
border: 0;
background: none;
cursor: pointer;
}
#sideToolButtons button:hover>img {
opacity: 1;
}
#sideToolButtons button>img {
width: 100%;
height: 100%;
opacity: 0.7;
}
#sideToolButtons .btn_disabled img {
opacity: 0.2;
cursor: default;
}
#sideToolButtons .btn_disabled:hover>img {
opacity: 0.2;
cursor: default;
}
#calcButton {
position: absolute;
bottom: 50px;
width: 30px !important;
right: 50%;
margin-right: -10px !important;
display: none;
}
#designConsole {
width: 100%;
position: absolute;
bottom: 0;
height: 60%;
min-height: 180px;
margin-bottom: 0;
}
#innerConsole {
position: relative;
color: #333;
height: 100%;
min-height: 40px;
font-size: 9pt;
border: #002774 1px solid;
overflow: hidden;
padding: 3px 6px;
}
#innerConsole:hover {
overflow: auto;
}
#innerConsole>p {
margin: 0;
padding: 0 !important;
text-align: left;
margin-bottom: 5px !important;
}
.lastEntry {
font-weight: bold;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<fieldset class="step">
<legend id="stepTitle_2">Line Design</legend>
<div id="stepDesc_2" class="txtbox">
Make a sketch of the required line design. The composition and length of the channels are visible if you draw or adapt the line.
</div>
<div id="toolsWrapper" class="form-group">
<label id='drawtoggle' class="col-md-3">
<input type="radio" id="penToggle" name="mouseToggle" value=0 checked>
<img src="./images/draw.png">
</label>
<label id='cursortoggle' class="col-md-3">
<input type="radio" id="selToggle" name="mouseToggle" value=1>
<img src="./images/cursor.png">
</label>
<div id="sideToolButtons" class="form-group">
<button type="button" id="delButton" class="col-md-6" style="margin-left: 20px;">
<img src="./images/trash.png" alt=""/>
</button>
<button type="button" id="zoomFitButton" class="col-md-6" style="margin-left: 20px;">
<img src="./images/zoom_fit.png" alt=""/>
</button>
</div>
<div id="designConsole" class="form-group">
<!-- <div id="designDefinitions" class = "col-md-6"></div> -->
<div id="innerConsole" class="col-md-12"></div>
</div>
</div>
<div id="designContainer"></div>
</fieldset>
Thank you.