How to place an animated checklist button right to text - javascript

I am using a template form I found which gives me a neat checklist form that I can use for a website I'm trying to develop (I'm doing this to learn)
So I want to know how to make these buttons:
appear on the right side of the text (I want to use RTL language)
To make it easier, here is the fiddle:
https://jsfiddle.net/h1jokddo/
I tried to modify the css code, adding "margin: right" to some of the properties but no luck:
body {
background: #069ffb;
color: #fff;
}
.ac-custom {
padding: 0 3em;
max-width: 900px;
margin: 0 auto;
}
.ac-custom ul,
.ac-custom ol {
list-style: none;
padding: 0;
margin: 0 auto;
max-width: 800px;
}
.ac-custom li {
margin: 0 auto;
padding: 2em 0;
position: relative;
}
.ac-custom label {
display: inline-block;
position: relative;
font-size: 2em;
padding: 0 0 0 80px;
vertical-align: top;
color: rgba(0, 0, 0, 0.2);
cursor: pointer;
-webkit-transition: color 0.3s;
transition: color 0.3s;
}
.ac-custom input[type="checkbox"],
.ac-custom label::before {
width: 50px;
height: 50px;
top: 50%;
left: 0;
margin-top: -25px;
position: absolute;
cursor: pointer;
}
.ac-custom input[type="checkbox"] {
opacity: 0;
-webkit-appearance: none;
display: inline-block;
vertical-align: middle;
z-index: 100;
}
.ac-custom label::before {
content: '';
border: 4px solid #fff;
-webkit-transition: opacity 0.3s;
transition: opacity 0.3s;
}
.ac-radio label::before {
border-radius: 50%;
}
.ac-custom input[type="checkbox"]:checked + label {
color: #fff;
}
.ac-custom input[type="checkbox"]:checked + label::before {
opacity: 0.8;
}
/* General SVG and path styles */
.ac-custom svg {
position: absolute;
width: 40px;
height: 40px;
top: 50%;
margin-top: -20px;
left: 5px;
pointer-events: none;
}
.ac-custom svg path {
stroke: #fdfcd3;
stroke-width: 13px;
stroke-linecap: round;
stroke-linejoin: round;
fill: none;
}
/* Box Fill */
.ac-boxfill svg path {
stroke-width: 8px;
}
I need to know what to change there.
As I stated before, this is something I'm doing in order to learn, this is how I learn at least, I take something that is already working, and try to find out what makes everything work.

Remove the padding from your label and add the desired amount of pixels to left of your checkbox in the css. Also add the amount of pixels to the left of the svg
Like so:
.ac-custom label {
display: inline-block;
position: relative;
font-size: 2em;
padding: 0 0 0 0px;
vertical-align: top;
color: rgba(0, 0, 0, 0.2);
cursor: pointer;
-webkit-transition: color 0.3s;
transition: color 0.3s;
}
.ac-custom input[type="checkbox"],
.ac-custom label::before {
width: 50px;
height: 50px;
top: 50%;
left: 50px;
margin-top: -25px;
position: absolute;
cursor: pointer;
}
.ac-custom svg {
position: absolute;
width: 40px;
height: 40px;
top: 50%;
margin-top: -20px;
left: 55px;
pointer-events: none;
}
See fiddle

Add the below code at the end of your css
.ac-custom label {
padding: 0;
}
.ac-custom input[type="checkbox"], .ac-custom label::before {
left: 40px;
}
.ac-custom svg {
top: 54%;
left: 49px;
}
Updated : https://jsfiddle.net/arifahmedjoy/h1jokddo/7/

Related

SweetAlert Icon overflow-y

I have an issue modifying my website. When I call Swal.fire(...), something like this happens:
Icon on the picture overflows and not renders properly(seems like scrollbar affects on icon render). How can I fix this? Thanks
Here is my custom css code:
* {
margin: 0px;
padding: 0px;
font-family: 'Roboto Mono', monospace;
overflow-x: hidden;
color: white;
user-select: none;
font-size: 20px;
}
h1 {
font-size: 60px;
}
body {
z-index: -2;
background-color: black;
}
#canvas1 {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
z-index:-1;
background: black;
}
.header {
text-align: center;
height: 100vh;
}
.header-title {
font-size: 70px;
font-weight: bold;
margin-top: 40vh;
}
section {
padding: 20vh;
}
.section-title {
font-size: 60px;
}
.section-text {
font-size: 25px;
}
footer {
height: 30vh;
background-color: rgb(24, 24, 24);
}
.navbar {
font-size: 40px;
position: fixed;
list-style-type: none;
overflow: hidden;
}
.navbar > li {
float: left;
}
.navbar > li a {
transition: .3s;
display: block;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.navbar > li a:hover {
background-color: rgba(255, 255, 255, 0.671);
}
input {
background-color: black;
margin: 20px;
}
.account-creator {
margin: auto;
width: 50%;
border: 3px solid white;
padding: 10px;
border-radius: 10px;
margin-top: 30vh;
padding: 10vh;
}
.account-creator {
margin-bottom: 100px;
}
.small-title {
font-size: 40px;
}
button {
background-color: black;
}
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 35px;
overflow-y: hidden;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
top: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #f3214f;
}
input:focus + .slider {
box-shadow: 0 0 1px #f3214f;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
.input_description{
font-size: 30px;
}
.simple-button {
background-color: #f3214f;
padding: 10px;
border-radius: 5px;
border: none;
transition: .4s;
margin: 30px;
}
.simple-button:hover {
transform: scale(1.2);
box-shadow: 0px 0px 10px #f3214faf;
}
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-thumb {
background-image: linear-gradient(45deg, rgb(255, 115, 0) 0%, rgb(255, 0, 0) 100%);
border-radius: 20px;
}
::-webkit-scrollbar-thumb:hover {
background-color: white;
background-image: none;
border-radius: 20px;
}
.clauses-field{
border: 3px solid white;
border-radius: 10px;
max-height: 300px;
position: absolute;
overflow-y: scroll;
margin-left: 40vw;
padding: 30px;
}
Idk maybe this code ruins everything, but it will be good if I don't need to change anything in here cause my website could just crash
For some resone you icon is overflowing so that orange line is scrollbar
add .sa-icon.sa-success { overflow:hidden }
this code in your css . if this dosent work , just inspect success icon and copy its class and add overflow:hidden to that.
if you still cant do it just copy popup code and add to your question , i will give you working code.

How to make a toggle button with vanilla javascript and css without any html

I tried to find a solution and people always gave either solutions with html or jQuery or what have you.
So I made one and thought it might be helpful for others.
let defaultSetting = "off"
const toggleButton = document.createElement('toggleButton');
toggleButton.onclick = function(){toggleSwitchTransformFunction()};
document.body.appendChild(toggleButton);
const toggleSwitchCircle = document.createElement('toggleSwitchCircle');
toggleButton.appendChild(toggleSwitchCircle);
function toggleSwitchTransformFunction() {
if(defaultSetting == "off"){
defaultSetting = "on"
toggleSwitchCircle.style.transform = "translateX(100%)"
toggleButton.style.background = "black"
// execute code when ON
} else if(defaultSetting == "on"){
defaultSetting = "off"
toggleSwitchCircle.style.transform = "translateX(0%)"
toggleButton.style.background = "white"
// execute code when OFF
}
}
toggleButton{
width: 84px;
min-width: 84px;
display: block;
padding: 4px;
border: 1px black solid;
border-radius: 60px;
transition: 0.5s;
}
toggleSwitchCircle {
display: block;
width: 40px;
height: 40px;
border: 1px black solid;
background-color: white;
border-radius: 50%;
transition: 0.5s;
}
You can also easily do a pure CSS toggle by using an input and label.
https://codepen.io/seanstopnik/pen/f0d8ba0f9b0a317c324ee16f49ba945c
document.body.innerHTML = document.body.innerHTML +
"<div class=\"toggle\"><input id=\"toggle1\" class=\"toggle__checkbox\" type=\"checkbox\"><label for=\"toggle1\" class=\"toggle__label\"></label></div>";
/* For demo only */
body {
font-family: sans-serif;
background: #2d4a65;
padding: 60px;
}
/* Toggle */
.toggle {
position: relative;
width: 80px;
height: 40px;
border-radius: 20px;
box-shadow: inset 0 2px 1px rgba(0, 0, 0, 0.1);
background-color: #1e3648;
overflow: hidden;
}
.toggle__checkbox {
position: absolute;
left: -9999px;
}
.toggle__label {
position: relative;
display: inline-block;
top: 4px;
left: 4px;
width: 32px;
height: 32px;
border-radius: 16px;
background-color: #fff;
transition: all 0.25s ease-in-out;
cursor: pointer;
}
.toggle__label:before, .toggle__label:after {
position: absolute;
top: 0;
color: #fff;
font-size: 13px;
font-weight: bold;
text-transform: uppercase;
line-height: 32px;
transition: all 0.15s ease-in-out;
}
.toggle__label:before {
left: -30px;
content: "on";
opacity: 0;
}
.toggle__label:after {
left: 37px;
content: "off";
opacity: 1;
}
.toggle__checkbox:checked ~ .toggle__label {
left: 44px;
}
.toggle__checkbox:checked ~ .toggle__label:before {
opacity: 1;
}
.toggle__checkbox:checked ~ .toggle__label:after {
opacity: 0;
}

CSS Vertical Button with vertical text

I need vertical button with written vertical text inside. It should not be turned to 90 degree. I need to add some hover effect to right side if mouse on it and give white space between words. I have tried white-space and word-space but it did not help.
Example:
.button {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
<script src="http://d3js.org/d3.v3.min.js"></script>
<button class="button" style="width:60px; height:600px; text-align:center;"><div style="width: 1ch; text-align:center; font: Consolas, Monaco, monospace;font-size:14pt; word-wrap: break-word;white-spacing: 3 px;">Online Sürücü Sifariş Et</div></button>
You can use transform:rotate(-90deg);
.button {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
transform:rotate(-90deg);
-webkit-transform:rotate(-90deg);
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
<button class="button" style=" text-align:center;">Online Sürücü Sifariş Et</button>
.button {
-webkit-writing-mode: vertical-rl;
writing-mode: vertical-rl;
text-orientation: upright;
}
I think this is what you want. The button is a vertical button and the text is all one letter below the next. I have used <br> tags for every new line. Have a look
.button {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
<script src="http://d3js.org/d3.v3.min.js"></script>
<button class="button" style="width:60px; height:600px; text-align:center;"><div style="width: 1ch; text-align:center; font: Consolas, Monaco, monospace;font-size:14pt; word-wrap: break-word;white-spacing: 3 px;">O<br>n<br>l<br>i<br>n<br>e<br><br>S<br>ü<br>r<br>ü<br>c<br>ü<br><br>S<br>i<br>f<br>a<br>r<br>i<br>ş<br><br>E<br>t<br></div></button>
There are several ways to accomplish what you're doing, but I like this one:
https://codepen.io/krabbypattified/pen/ybzway
It's a weird CSS attribute, but the imporant code is: white-space: pre-line;
Edit: there's also text-orientation, but that's not supported by many browsers.
Edit: updated the CodePen html

Fullpage.js - Dot Navigation Styling

I'm trying to style the dot navigation for Fullpage.JS however I'm having some trouble.
Here's a fiddle of my code and what i currently have:
https://jsfiddle.net/my9tqcho/
I'm trying to add the "fill up" effect, as seen HERE.
Here's the source code for the effect:
.dotstyle ul {
position: relative;
display: inline-block;
margin: 0;
padding: 0;
list-style: none;
cursor: default;
}
.dotstyle li {
position: relative;
display: block;
float: left;
margin: 0 16px;
width: 16px;
height: 16px;
cursor: pointer;
}
.dotstyle li a {
top: 0;
left: 0;
width: 100%;
height: 100%;
outline: none;
border-radius: 50%;
background-color: #fff;
background-color: rgba(255,255,255,0.3);
text-indent: -999em;
cursor: pointer; /* make the text accessible to screen readers */
position: absolute;
}
/* Fill up */
.dotstyle-fillup li a {
overflow: hidden;
background-color: rgba(0,0,0,0);
box-shadow: inset 0 0 0 2px rgba(255,255,255,1);
transition: background 0.3s;
}
.dotstyle-fillup li a::after {
content: '';
position: absolute;
bottom: 0;
height: 0;
left: 0;
width: 100%;
background-color: #fff;
box-shadow: 0 0 1px #fff;
transition: height 0.3s;
}
.dotstyle-fillup li a:hover,
.dotstyle-fillup li a:focus {
background-color: rgba(0,0,0,0.2);
}
.dotstyle-fillup li.current a::after {
height: 100%;
}
So far I found THIS answer from the creator of fullpage.js, but I seem to miss something and I can't figure out what it is.
I made a fork of your jsfiddle and got it to work here https://jsfiddle.net/6z67g7v6/
What you want to do is to set overflow: hidden and box-shadow: inset 0 0 0 2px white so that it allows for such 'filled' effect.
The pseudo element styling is like the source code.
Cheers.

Masking issue when sliding multiple divs behind a line

I have a CSS animation effect that's difficult to implement due to layering problems. See the snippet below:
var toggle = document.getElementById('toggle');
function toggleF() {
'use strict';
document.querySelector('nav').classList.add('fuzzyState');
}
toggle.addEventListener('click', toggleF);
body {
height: 90%;
color: #222;
text-align: center overflow:hidden;
}
button {
outline: 0;
cursor: pointer
}
#toggle {
float: left;
width: 38px;
height: 38px;
padding: 5px;
margin: auto;
background: #fff;
color: #666;
border: 0;
font-size: 150%
}
#toggle:hover {
background: #222;
color: #eee;
user-select: none;
-webkit-user-select: none
}
#toggle:active {
background: #022;
color: #fff
}
nav ul:after {
content"";
display: block;
clear: both
}
nav ul {
height: 150px;
margin: 0;
padding: 0;
font-size: 150%
}
nav li {
width: 140px;
height: 140px;
margin: 5px;
float: left;
list-style: none;
user-select: none;
-webkit-user-select: none
}
nav button {
display: block;
position: relative;
top: 50%;
width: 100%;
height: 100%;
background: transparent;
border: 0;
text-transform: uppercase;
transform: translateY(-50%)
}
nav button:hover {
background: #022;
color: #eee
}
nav button:active {
background: #033;
color: #fff
}
ul hr {
position: relative;
top: 50%;
width: 1px;
height: 90px;
margin: 10px;
background: #eee;
border: 0;
float: left;
transform: translateY(-50%);
z-index: 2
}
nav.fuzzyState #dos {
transform: translateX(230px)
}
nav.fuzzyState #uno {
transform: translateX(400px);
-webkit-filter: blur(1px)
}
nav.fuzzyState #tres {
/*transform:translateX(-230px)*/
}
nav #tres {
position: relative;
z-index: 1
}
#leftNavMask {
background: #fff;
position: absolute;
top: 15%;
right: 0;
left: 356px;
width: 200px;
height: 190px;
text-align: justify;
transform: translateY(-50%);
}
#rightNavMask {
background: #fff;
position: absolute;
top: 15%;
right: 0;
left: 156px;
width: 200px;
height: 190px;
text-align: justify;
transform: translateY(-50%);
z-index: -1
}
#dos,
#tres {
transition: transform 0.7s ease-in-out
}
#uno {
transition: transform 1s ease-in-out, -webkit-filter 1s ease-in-out;
}
<button id="toggle">+</button>
<nav>
<ul>
<li id="uno"><button>uno</button></li>
<li id="dos"><button>dos</button></li>
<hr>
<li id="tres"><button>tres</button></li>
<div id="leftNavMask"></div>
<div id="rightNavMask"></div>
</ul>
</nav>
After the + button is clicked my goal is to make the tres button slide to the left while being masked just like the uno and dos buttons, except in the opposite direction. It seems impossible to pull off because whatever z-index I give any elements there's no way to have the left mask on top of the correct elements while simultaneously having the right mask do its job. Are there any simple ways to do this without jQuery? Thanks.
To clarify: The uno and dos buttons are currently going under a div that is colored to match the background. I need the tres button to slide left under a second div that is somehow on top of the tres button to mask it but also below the uno and dos buttons so they aren't blocked at the beginning.
Long time since this question was asked, therefore, most probably you have found a solution already. But just in case, here you have a possible approach to what you wanted to achieve.
Instead of using absolute positioned divs with the same color of the background to cover the animated li elements, why don't use an overflow hidden property in the ul container? If you do this, the ul will act as a "mask" and when the li elements get animated outside the ul, they will be automatically "hidden". Take a look at your snippet already modified using this approach (I have used two ul elements to animate the li elements separately):
I saw that you placed an hr (and two div) inside the ul element and a ul should only contain li elements. For this solution, I used a pseudo-element to mimic the vertical line.
var toggle = document.getElementById('toggle');
function toggleF() {
document.querySelector('nav').classList.toggle('fuzzyState');
}
toggle.addEventListener('click', toggleF);
body {
color: #222;
}
button {
cursor: pointer;
outline: 0;
}
#toggle {
background: #fff;
border: 0;
color: #666;
float: left;
font-size: 150%;
height: 38px;
margin: auto;
padding: 5px;
width: 38px;
}
#toggle:hover {
background: #222;
color: #eee;
user-select: none;
}
#toggle:active {
background: #022;
color: #fff
}
nav ul {
display: inline-block;
font-size: 150%;
margin: 0;
overflow: hidden;
padding: 0;
position: relative;
}
nav ul.left::after {
content: "";
display: block;
border-right: 1px solid #eee;
height: 90px;
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
}
nav li {
display: inline-block;
height: 140px;
list-style: none;
margin: 5px;
user-select: none;
transition: transform 0.7s ease-in-out;
width: 140px;
}
nav button {
background: transparent;
border: 0;
display: block;
height: 100%;
position: relative;
text-transform: uppercase;
top: 50%;
transform: translateY(-50%);
width: 100%;
}
nav button:hover {
background: #022;
color: #eee;
}
nav button:active {
background: #033;
color: #fff;
}
nav.fuzzyState ul > li {
pointer-events: none;
}
nav.fuzzyState ul.left > li {
transform: translateX(200%);
}
nav.fuzzyState ul.right > li {
transform: translateX(-100%);
}
<button id="toggle">+</button>
<nav>
<ul class="left">
<li><button>uno</button></li>
<li><button>dos</button></li>
</ul>
<ul class="right">
<li><button>tres</button></li>
</ul>
</nav>

Categories