I am building this simple form (took the code from here https://codepen.io/JeromeRenders/pen/EPNxPv ) but the bullet points end up being duplicated on my page. How come? Here following is the html for the form and the css I am using. Thank you. I also added JS because that is what is creating the li list.
body fieldset {
box-shadow: 0 8px 10px #29a329;
}
body.error {
background: #f04000;
}
body.error fieldset {
box-shadow: 0 8px 10px #bd3200;
}
ul.items {
position: absolute;
width: 30px;
height: auto;
top: 50%;
left: -60px;
transform: translateY(-50%);
}
ul.items li {
width: 8px;
height: 8px;
margin: 10px 0;
background: white;
border-radius: 50%;
opacity: 0.4;
cursor: pointer;
}
ul.items li.active {
opacity: 1;
}
form {
position: relative;
width: 300px;
height: 60px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
form fieldset {
position: absolute;
width: 300px;
height: 60px;
background: white;
border-radius: 3px;
opacity: 0;
transform: scale(0.2);
transition: all 0.4s ease-in-out;
}
form fieldset input,
form fieldset p {
display: inline-block;
width: 200px;
margin-left: 50px;
color: #333333;
font-size: 16px;
letter-spacing: 1px;
}
form fieldset p {
margin-top: 22px;
text-align: center;
}
form fieldset input {
height: 40px;
margin-top: 8px;
border: none;
outline: none;
}
body.error fieldset {
transform-origin: 50% 100%;
animation: error 0.3s ease-out;
}
<form>
<ul class="items"></ul>
<fieldset class="username enable">
<div class="icon left"><i class="user"></i></div>
<input type="text" name="username" placeholder="Username" />
<div class="icon right button"><i class="arrow"></i></div>
</fieldset>
<fieldset class="email">
<div class="icon left"><i class="letter"></i></div>
<input type="mail" name="email" placeholder="Email" />
<div class="icon right button"><i class="arrow"></i></div>
</fieldset>
<fieldset class="thanks">
<div class="icon left"></div>
<p>Thanks for your time</p>
<div class="icon right"></div>
</fieldset>
</form>
JS
function init() {
// Generate li foreach fieldset
for (var i = 0; i < count; i++) {
var ul = document.querySelector('ul.items'),
li = document.createElement("li");
ul.appendChild(li);
}
// Add class active on first li
ul.firstChild.classList.add('active');
}
Here is an image of what I get:
Duplicated bullet points
Below code useful for that:
css:
body {
background: #33cc33;
font-family: sans-serif;
}
body fieldset {
box-shadow: 0 8px 10px #29a329;
}
body.error {
background: #f04000;
}
body.error fieldset {
box-shadow: 0 8px 10px #bd3200;
}
h1, h2 {
position: absolute;
left: 50%;
transform: translateX(-50%);
font-family: sans-serif;
text-transform: uppercase;
letter-spacing: 2px;
}
h1 {
top: 24px;
color: white;
font-size: 12px;
}
h2 {
top: 44px;
color: white;
font-size: 10px;
opacity: 0.7;
}
ul.items {
position: absolute;
width: 30px;
height: auto;
top: 50%;
left: -60px;
transform: translateY(-50%);
}
ul.items li {
width: 8px;
height: 8px;
margin: 10px 0;
background: white;
border-radius: 50%;
opacity: 0.4;
cursor: pointer;
}
ul.items li.active {
opacity: 1;
}
form {
position: absolute;
width: 300px;
height: 60px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
form fieldset {
position: absolute;
width: 300px;
height: 60px;
background: white;
border-radius: 3px;
opacity: 0;
transform: scale(0.2);
transition: all 0.4s ease-in-out;
}
form fieldset input, form fieldset p {
display: inline-block;
width: 200px;
margin-left: 50px;
color: #333333;
font-size: 16px;
letter-spacing: 1px;
}
form fieldset p {
margin-top: 22px;
text-align: center;
}
form fieldset input {
height: 40px;
margin-top: 8px;
border: none;
outline: none;
}
form fieldset .icon {
position: absolute;
width: 30px;
height: 30px;
top: 15px;
transition: all 0.4s ease;
}
form fieldset .icon i {
position: absolute;
display: block;
}
form fieldset .icon i::before, form fieldset .icon i::after {
position: absolute;
content: "";
}
form fieldset .icon.left {
left: 10px;
}
form fieldset .icon.right {
right: 10px;
cursor: pointer;
}
form fieldset .icon.button:hover {
background: #f2f2f2;
border-radius: 3px;
transition: all 0.4s ease;
}
form fieldset.enable {
z-index: 1;
opacity: 1;
transition: all 0.5s ease-out 0.2s;
transform: scale(1);
animation: enable 0.5s ease-out 0.2s;
}
form fieldset.disable {
opacity: 0;
transition: all 0.3s ease-in;
transform: translateY(120px) scale(0.9);
}
body.error fieldset {
transform-origin: 50% 100%;
animation: error 0.3s ease-out;
}
#keyframes enable {
0% {
opacity: 0;
transform: scale(0.2);
}
60% {
transform: scale(1.1);
}
100% {
opacity: 1;
transform: scale(1);
}
}
#keyframes error {
0%, 50%, 100% {
transform: rotate(0deg);
}
25% {
transform: rotate(-3deg);
}
75% {
transform: rotate(3deg);
}
}
/**
* Icons in CSS, long as f****
*/
.icon .arrow {
width: 2px;
height: 17px;
top: 5px;
left: 14px;
background: #333333;
}
.icon .arrow::before {
width: 6px;
height: 6px;
bottom: -1px;
left: -3px;
border-color: #333333;
border-right: 2px solid;
border-bottom: 2px solid;
transform: rotate(45deg);
}
.icon .user {
width: 20px;
height: 10px;
bottom: 5px;
left: 5px;
box-shadow: 0 0 0 2px #333333 inset;
border-radius: 6px 6px 3px 3px;
}
.icon .user::before {
width: 10px;
height: 10px;
top: -9px;
left: 5px;
box-shadow: 0 0 0 2px #333333 inset;
border-radius: 50%;
}
.icon .letter {
width: 20px;
height: 12px;
top: 9px;
left: 5px;
box-shadow: 0 0 0 2px #333333 inset;
border-radius: 3px;
}
.icon .letter::before, .icon .letter::after {
width: 11px;
height: 2px;
top: 4px;
background: #333333;
}
.icon .letter::before {
left: 0;
transform: rotate(30deg);
}
.icon .letter::after {
right: 0;
transform: rotate(-30deg);
}
.icon .lock {
width: 20px;
height: 16px;
top: 9px;
left: 5px;
box-shadow: 0 0 0 2px #333333 inset;
border-radius: 3px;
}
.icon .lock::before {
width: 8px;
height: 8px;
top: -4px;
left: 4px;
border: 2px solid transparent;
border-top: 2px solid #333333;
border-right: 2px solid #333333;
border-radius: 50%;
transform: rotate(-45deg);
}
.icon .lock::after {
width: 6px;
height: 7px;
top: 4px;
left: 7px;
box-shadow: 0 0 0 2px #333333 inset;
}
.icon .heart {
width: 10px;
height: 10px;
top: 11px;
left: 7px;
background: #ff5233;
transform: rotate(45deg);
}
.icon .heart::before, .icon .heart::after {
width: 10px;
height: 10px;
border-radius: 50%;
background: #ff5233;
}
.icon .heart::before {
left: -6px;
}
.icon .heart::after {
top: -6px;
}
HTML:
<form>
<ul class="items"><li class="active"></li><li></li><li></li><li></li></ul>
<fieldset class="username enable">
<div class="icon left"><i class="user"></i></div>
<input type="text" name="username" placeholder="Username"/>
<div class="icon right button"><i class="arrow"></i></div>
</fieldset>
<fieldset class="email">
<div class="icon left"><i class="letter"></i></div>
<input type="mail" name="email" placeholder="Email"/>
<div class="icon right button"><i class="arrow"></i></div>
</fieldset>
<fieldset class="password">
<div class="icon left"><i class="lock"></i></div>
<input type="password" name="password" placeholder="Password"/>
<div class="icon right button"><i class="arrow"></i></div>
</fieldset>
<fieldset class="thanks">
<div class="icon left"><i class="heart"></i></div>
<p>Thanks for your time</p>
<div class="icon right"><i class="heart"></i></div>
</fieldset>
</form>
JS:
function init() {
// Generate li foreach fieldset
for (var i = 0; i < count; i++) {if (window.CP.shouldStopExecution(1)){break;}
var ul = document.querySelector('ul.items'),
li = document.createElement("li");
ul.appendChild(li);
}
window.CP.exitedLoop(1);
// Add class active on first li
ul.firstChild.classList.add('active');
}
function next(target) {
var input = target.previousElementSibling;
// Check if input is empty
if (input.value === '') {
body.classList.add('error');
} else {
body.classList.remove('error');
var enable = document.querySelector('form fieldset.enable'),
nextEnable = enable.nextElementSibling;
enable.classList.remove('enable');
enable.classList.add('disable');
nextEnable.classList.add('enable');
// Switch active class on left list
var active = document.querySelector('ul.items li.active'),
nextActive = active.nextElementSibling;
active.classList.remove('active');
nextActive.classList.add('active');
}
}
function keyDown(event) {
var key = event.keyCode,
target = document.querySelector('fieldset.enable .button');
if (key == 13 || key == 9) next(target);
}
var body = document.querySelector('body'),
form = document.querySelector('form'),
count = form.querySelectorAll('fieldset').length;
window.onload = init;
document.body.onmouseup = function (event) {
var target = event.target || event.toElement;
if (target.classList.contains("button")) next(target);
};
document.addEventListener("keydown", keyDown, false);
Related
I'm trying to add a popup block which will work differently for each row. I used same checkbox id to work with CSS. But it always checks the first option. As a result, the first option in the list get deleted (as I'm working with delete button) instead of the selected one
This is my HTML part :
{% for item in items %}
<input type="checkbox" id="popup">
<label for="popup" class="del_btn">Delete</label>
<div class="popup-content">
<div class="pop-header">
<h2>Confirm deletion?</h2>
<label for="popup" class="fa fa-times"></label>
</div>
<label for="popup" class="fa fa-exclamation"></label>
<p>Once deleted, all data related to it can't be restored again.<br>Proceed to delete?</p>
<div class="line"></div>
<a href="{% url 'delete_item' item.id %}" class="btn btn-danger btn-sm" role="button">
<i class="fa fa-trash"></i>
<span>Delete</span>
</a>
<label for="popup" class="close-btn">Cancel</label>
</div>
And my CSS part :
.popup-content
{
top: 50%;
left: 50%;
opacity: 0;
visibility: hidden;
transform: translate(-50%, -50%);
position: fixed;
width: 450px;
height: 350px;
transition: 0.3s ease-in;
background-color: khaki;
border-radius: 3px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.4);
}
/* #popup
{
display: none;
} */
#popup:checked ~ .popup-content
{
opacity: 1;
visibility: visible;
}
.pop-header
{
height: 90px;
background-color: #27AE60;
overflow: hidden;
border-radius: 3px 3px 0 0;
box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.2);
}
.pop-header h2
{
font-size: 40px;
line-height: 45px;
color: white;
font-weight: normal;
}
.popup-content p
{
font-size: 16px;
color: red;
text-align: center;
}
.line
{
position: absolute;
bottom: 60px;
height: 1px;
width: 100%;
background-color: black;
}
.fa-times
{
position: absolute;
right: 20px;
top: 35px;
color: #E8F7FC;
font-size: 20px;
font-weight: bold;
cursor: pointer;
}
.fa-exclamation
{
font-size: 50px;
color: #27AE60;
height: 80px;
width: 80px;
text-align: center;
border: 2px solid #27AE60;
border-radius: 50%;
box-sizing: border-box;
padding-top: 13px;
margin: 30px 0;
}
.del_btn
{
font-size: inherit;
display: block;
width: 62.36px;
height: 33px;
line-height: 33px;
background: #d9534f;
border: 1px solid #d9534f;
border-radius: 3px;
cursor: pointer;
transition: 0.5s;
}
.del_btn:hover
{
background: red;
}
.close-btn
{
position: absolute;
bottom: 2.5px;
right: 10px;
font-size: 18px;
color: #27AE60;
border: 1px solid #27AE60;
border-radius: 3px;
padding: 8px 10px;
cursor: pointer;
}
.close-btn:hover
{
background-color: #27AE60;
color: khaki;
transition-delay: 0.1s;
}
.popup-content .btn-danger
{
position: absolute;
bottom: 6px;
right: 100px;
font-size: 18px;
padding: 8px 10px;
}
I also tried
<input type="checkbox" id="popup popup_{{item.id}}>
It successfully creates dynamically different id for different row, but CSS doesn't work in that case.
The :checked pseudo-class in CSS is only associated with input (<input>) elements of type radio and checkbox. You can rewrite your CSS as follows:
input[type=checkbox]:checked#popup ~ .popup-content {
opacity: 1;
visibility: visible;
}
The usage of id suggests that there is only one popup element, I would suggest using a class instead:
input[type=checkbox]:checked.popup ~ .popup-content {
opacity: 1;
visibility: visible;
}
You should not have same id for two elements and cannot have two ids for an element. Make the input element as this
<input type="checkbox" class="popupCheckbox" id="popup_{{item.id}}">
And CSS selector as this .popupCheckbox
I am new to CSS and have a question that is probably simple to answer, though I am not sure which class to start with.
My objective is to put text that fit neatly inside of range slider
I am using public range slider example:
let app = (() => {
function updateSlider(element) {
if (element) {
let parent = element.parentElement,
lastValue = parent.getAttribute('data-slider-value');
if (lastValue === element.value) {
return; // No value change, no need to update then
}
parent.setAttribute('data-slider-value', element.value);
let $thumb = parent.querySelector('.range-slider__thumb'),
$bar = parent.querySelector('.range-slider__bar'),
pct = element.value * ((parent.clientHeight - $thumb.clientHeight) / parent.clientHeight);
$thumb.style.bottom = `${pct}%`;
$bar.style.height = `calc(${pct}% + ${$thumb.clientHeight / 2}px)`;
$thumb.textContent = `${element.value}%`;
}
}
return {
updateSlider: updateSlider };
})();
(function initAndSetupTheSliders() {
const inputs = [].slice.call(document.querySelectorAll('.range-slider input'));
inputs.forEach(input => input.setAttribute('value', '50'));
inputs.forEach(input => app.updateSlider(input));
// Cross-browser support where value changes instantly as you drag the handle, therefore two event types.
inputs.forEach(input => input.addEventListener('input', element => app.updateSlider(input)));
inputs.forEach(input => input.addEventListener('change', element => app.updateSlider(input)));
})();
.range-slider {
position: relative;
text-align: center;
height: 300px;
max-height: 100%;
margin-top: 15%;
/*margin-bottom: 5vh;*/
}
/*.range-slider:before {
position: absolute;
top: -2em;
//left: .5em;
content: attr(data-slider-value) "%";
color: red;
font-size: 25px;
}*/
.range-slider__thumb {
position: absolute;
left: 32%;
width: 45px;
height: 45px;
line-height: 45px;
font-weight: bold;
background: white;
color: black;
background: url('../../../assets/images/button_round_dark.png');
font-size: 80%;
box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.9);
border-radius: 50%;
pointer-events: none;
z-index:999;
// position: absolute;
// left: 42%;
// width: 30px;
// height: 30px;
// line-height: 30px;
// background: white;
// color: black;
// font-size: 50%;
// font-size: 80%;
// box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.9);
// border-radius: 50%;
// pointer-events: none;
// z-index:999;
}
.range-slider__thumb_start{
position: absolute;
left: 33%;
width: 45px;
height: 45px;
line-height: 30px;
background: white;
color: black;
background: url('../../../assets/images/button_round_dark.png');
font-size: 60%;
box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.9);
border-radius: 50%;
pointer-events: none;
z-index:99;
bottom: 0px;
}
.range-slider__bar {
left: 42%;
bottom: 0;
position: absolute;
background: linear-gradient(to bottom, #c00000 0%, #ffe200 100%);
pointer-events: none;
width: 20px;
border-radius: 10px;
}
.range-slider input[type=range][orient=vertical] {
position: relative;
margin: 0;
height: 100%;
width: 100%;
display: inline-block;
position: relative;
writing-mode: bt-lr;
-webkit-appearance: slider-vertical;
}
.range-slider input[type=range][orient=vertical]::-webkit-slider-runnable-track, .range-slider input[type=range][orient=vertical]::-webkit-slider-thumb {
-webkit-appearance: none;
}
.range-slider input[type=range][orient=vertical]::-webkit-slider-runnable-track {
border: none;
background: orangered;
width: 18px;
border-color: #B94F1B;
border-radius: 10px;
//box-shadow: 0 0 0 20px rgba(96, 96, 96, 0.1);
//-webkit-box-shadow: 5px 38px 0px 53px rgba(0,0,0,0.35);
//-moz-box-shadow: 5px 38px 0px 53px rgba(0,0,0,0.35);
box-shadow: 0px 20px 0px 40px rgba(96, 96, 96, 0.1);
}
.range-slider input[type=range][orient=vertical]::-moz-range-track {
border: none;
background: white;
width: 18px;
border-color: #343440;
border-radius: 10px;
//box-shadow: 0 0 0 2px #3D3D4A;
}
.range-slider input[type=range][orient=vertical]::-ms-track {
border: none;
background: white;
width: 18px;
border-color: #343440;
border-radius: 10px;
box-shadow: 0 0 0 2px #3D3D4A;
color: transparent;
height: 100%;
}
.range-slider input[type=range][orient=vertical]::-ms-fill-lower, .range-slider input[type=range][orient=vertical]::-ms-fill-upper, .range-slider input[type=range][orient=vertical]::-ms-tooltip {
display: none;
}
.range-slider input[type=range][orient=vertical]::-webkit-slider-thumb {
width: 30px;
height: 30px;
opacity: 0;
}
.range-slider input[type=range][orient=vertical]::-moz-range-thumb {
width: 30px;
height: 30px;
opacity: 0;
}
.range-slider input[type=range][orient=vertical]::-ms-thumb {
width: 30px;
height: 30px;
opacity: 0;
}
.range-slider-text{
font-size: 1rem;
color: red;
text-transform: uppercase;
letter-spacing: 3px;
position: absolute;
bottom: 0;
left: 0;
margin-left: -30px;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
-ms-transform-origin: 0 0;
-o-transform-origin: 0 0;
transform-origin: 0 0;
}
<div class="range-slider" id="range_slider">
<input type="range" orient="vertical" id="desire" name="desire" min="{{min}}" max="{{max}}" />
<div class="range-slider__bar"></div>
<div class="range-slider-text">Header Two</div>
<div class="range-slider__thumb"></div>
<div class="bubble" id="me" style="display: none">slide to provide your feedback</div>
<!-- <div class="range-slider__thumb_start"></div> -->
<div class="range-slider__line"></div>
</div>
I am new to CSS and have a question that is probably simple to answer, though I am not sure which class to start with.
My objective is to put text that fit neatly inside of range slider
I am using public range slider example:
Like
I just update your code with few CSS and HTML changes, I hope it'll help you out. Thanks
Add display: flex;, justify-content: center; and align-items: center CSS in .range-slider__bar.
.range-slider__bar {
left: 42%;
bottom: 0;
position: absolute;
background: linear-gradient(to bottom, #c00000 0%, #ffe200 100%);
pointer-events: none;
width: 20px;
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
}
Also, add slider-text css.
.slider-text {
transform: rotate(-90deg);
white-space: nowrap;
}
In HTML i just add <div class="slider-text">My Desire</div> inside of your <div class="range-slider__bar">.
let app = (() => {
function updateSlider(element) {
if (element) {
let parent = element.parentElement,
lastValue = parent.getAttribute('data-slider-value');
if (lastValue === element.value) {
return; // No value change, no need to update then
}
parent.setAttribute('data-slider-value', element.value);
let $thumb = parent.querySelector('.range-slider__thumb'),
$bar = parent.querySelector('.range-slider__bar'),
pct = element.value * ((parent.clientHeight - $thumb.clientHeight) / parent.clientHeight);
$thumb.style.bottom = `${pct}%`;
$bar.style.height = `calc(${pct}% + ${$thumb.clientHeight / 2}px)`;
$thumb.textContent = `${element.value}%`;
}
}
return {
updateSlider: updateSlider };
})();
(function initAndSetupTheSliders() {
const inputs = [].slice.call(document.querySelectorAll('.range-slider input'));
inputs.forEach(input => input.setAttribute('value', '50'));
inputs.forEach(input => app.updateSlider(input));
// Cross-browser support where value changes instantly as you drag the handle, therefore two event types.
inputs.forEach(input => input.addEventListener('input', element => app.updateSlider(input)));
inputs.forEach(input => input.addEventListener('change', element => app.updateSlider(input)));
})();
.range-slider {
position: relative;
text-align: center;
height: 300px;
max-height: 100%;
margin-top: 15%;
/*margin-bottom: 5vh;*/
}
/*.range-slider:before {
position: absolute;
top: -2em;
//left: .5em;
content: attr(data-slider-value) "%";
color: red;
font-size: 25px;
}*/
.range-slider__thumb {
position: absolute;
left: 32%;
width: 45px;
height: 45px;
line-height: 45px;
font-weight: bold;
background: white;
color: black;
background: url('../../../assets/images/button_round_dark.png');
font-size: 80%;
box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.9);
border-radius: 50%;
pointer-events: none;
z-index:999;
// position: absolute;
// left: 42%;
// width: 30px;
// height: 30px;
// line-height: 30px;
// background: white;
// color: black;
// font-size: 50%;
// font-size: 80%;
// box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.9);
// border-radius: 50%;
// pointer-events: none;
// z-index:999;
}
.range-slider__thumb_start{
position: absolute;
left: 33%;
width: 45px;
height: 45px;
line-height: 30px;
background: white;
color: black;
background: url('../../../assets/images/button_round_dark.png');
font-size: 60%;
box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.9);
border-radius: 50%;
pointer-events: none;
z-index:99;
bottom: 0px;
}
.range-slider__bar {
left: 42%;
bottom: 0;
position: absolute;
background: linear-gradient(to bottom, #c00000 0%, #ffe200 100%);
pointer-events: none;
width: 20px;
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
}
.slider-text {
transform: rotate(-90deg);
white-space: nowrap;
}
.range-slider input[type=range][orient=vertical] {
position: relative;
margin: 0;
height: 100%;
width: 100%;
display: inline-block;
position: relative;
writing-mode: bt-lr;
-webkit-appearance: slider-vertical;
}
.range-slider input[type=range][orient=vertical]::-webkit-slider-runnable-track, .range-slider input[type=range][orient=vertical]::-webkit-slider-thumb {
-webkit-appearance: none;
}
.range-slider input[type=range][orient=vertical]::-webkit-slider-runnable-track {
border: none;
background: orangered;
width: 18px;
border-color: #B94F1B;
border-radius: 10px;
//box-shadow: 0 0 0 20px rgba(96, 96, 96, 0.1);
//-webkit-box-shadow: 5px 38px 0px 53px rgba(0,0,0,0.35);
//-moz-box-shadow: 5px 38px 0px 53px rgba(0,0,0,0.35);
box-shadow: 0px 20px 0px 40px rgba(96, 96, 96, 0.1);
}
.range-slider input[type=range][orient=vertical]::-moz-range-track {
border: none;
background: white;
width: 18px;
border-color: #343440;
border-radius: 10px;
//box-shadow: 0 0 0 2px #3D3D4A;
}
.range-slider input[type=range][orient=vertical]::-ms-track {
border: none;
background: white;
width: 18px;
border-color: #343440;
border-radius: 10px;
box-shadow: 0 0 0 2px #3D3D4A;
color: transparent;
height: 100%;
}
.range-slider input[type=range][orient=vertical]::-ms-fill-lower, .range-slider input[type=range][orient=vertical]::-ms-fill-upper, .range-slider input[type=range][orient=vertical]::-ms-tooltip {
display: none;
}
.range-slider input[type=range][orient=vertical]::-webkit-slider-thumb {
width: 30px;
height: 30px;
opacity: 0;
}
.range-slider input[type=range][orient=vertical]::-moz-range-thumb {
width: 30px;
height: 30px;
opacity: 0;
}
.range-slider input[type=range][orient=vertical]::-ms-thumb {
width: 30px;
height: 30px;
opacity: 0;
}
.range-slider-text{
font-size: 1rem;
color: red;
text-transform: uppercase;
letter-spacing: 3px;
position: absolute;
bottom: 0;
left: 0;
margin-left: -30px;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
-ms-transform-origin: 0 0;
-o-transform-origin: 0 0;
transform-origin: 0 0;
}
<div class="range-slider" id="range_slider">
<input type="range" orient="vertical" id="desire" name="desire" min="{{min}}" max="{{max}}" />
<div class="range-slider__bar">
<div class="slider-text">My Desire</div>
</div>
<div class="range-slider-text">Header Two</div>
<div class="range-slider__thumb"></div>
<div class="bubble" id="me" style="display: none">slide to provide your feedback</div>
<!-- <div class="range-slider__thumb_start"></div> -->
<div class="range-slider__line"></div>
</div>
This question already has answers here:
How do I give text or an image a transparent background using CSS?
(29 answers)
Opacity of background-color, but not the text [duplicate]
(5 answers)
Closed 4 years ago.
I find myself having problems in controlling the opacity of my items inside my container. The container should be the only one that is transparent but unfortunately all the items inside my container began to go transparent even though I already establish opacity: 1; to them.
Here is my code...
HTML
<!DOCTYPE html>
<html>
<head>
<title>Dino-Jump</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name = "viewport" content = "width=device-width, initial-scale=1.0">
</head>
<body class = "bg">
<div id = container>
<img src="Pics/user.jpg" id = "user">
<form action = "action-login">
<div id = "login-box">
<h1 class = "label1">Login</h1>
<div class = "textbox">
<i class = "fa fa-user" aria-hidden = "true"></i>
<input type="text" name="uname" placeholder="Username" required = "true">
</div>
<div class = "textbox">
<i class = "fa fa-lock" aria-hidden = "true"></i>
<input type="password" name="pword" placeholder="Password" required = "true">
</div>
<input class = "btn" type = "button" name = "login" value = "Login">
<a id = "forget" href=""> Forget Password </a>
<a id = "reg" href=""> Register </a>
</form>
</div>
</div>
<img src="Pics/title.png" id="game-title">
<div class = "footer">
<p>© Copyrights Dino-Jump ZRH.Group 10.20.20.18.2.37</p>
</div>
</body>
</html>
CSS
/**Style**/
#import "https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css";
#media screen and (min-width:768){
.bg{
width: 100%;
margin: 0 auto;
padding: 0 auto;
display: block;
font-family: sans-serif;
background-image: url("Pics/bg.jpg");
background-repeat: no-repeat;
background-size: 100%;
}
img{
width: 100%;
}
}
/**bofy**/
.bg{
margin: 0 auto;
padding: 0 auto;
font-family: sans-serif;
background-image: url("Pics/bg03.jpg");
background-repeat: no-repeat;
background-size: 100%;
}
#user{
opacity: 1;
background-image: url("Pics/user.jpg");
width: 135px;
height: 135px;
margin: 0 auto;
padding: 0 auto;
border-radius: 50%;
border: 4px solid #ffbd04;
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10;
}
#container{
opacity: 0.5;
margin: 0 auto;
padding: 0 auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 380px;
height: 480px;
background: #000;
border: 4px solid #ffbd04;
border-radius: 20px;
}
#login-box{
opacity: 1;
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
color: #fff;
}
#login-box h1{
float: left;
font-size: 40px;
border-bottom: 4px solid #ffbd04;
margin-bottom: 50px;
padding: 13px 0;
}
.textbox{
width: 100%;
overflow: hidden;
font-size: 20px;
padding: 8px 0;
margin: 8px 0;
border-bottom: 1px solid #ffbd04;
}
.texbox i{
width: 26px;
float: left;
text-align: center;
}
.textbox input{
border: none;
outline: none;
background: none;
color: #fff;
font-size: 18px;
width: 80%;
float: left;
margin: 0 10px;
}
::placeholder {
color: #fff;
}
[placeholder]:focus::-webkit-input-placeholder {
transition: text-indent 0.3s 0.3s ease;
text-indent: -100%;
opacity: 1;
}
.btn{
width: 100%;
background: none;
border: 2px solid #ffbd04;
border-radius: 10px;
color: #fff;
padding: 5px;
font-size: 18px;
margin: 12px;
transition: .6s;
overflow: hidden;
}
.btn:focus{
outline: none;
}
.btn:before{
content: '';
display: block;
position: absolute;
background: rgba(255,255,255,.5);
opacity: 0.5;
filter: blur(30px);
transform: translateX(-130px) skewX(-15deg);
}
.btn:after{
content: '';
display: block;
position: absolute;
background: rgba(255,255,255,.5);
opacity: 0;
filter: blur(30px);
transform: translate(-100px) scaleX(-15deg);
}
.btn:hover{
background: #ffbd04;
cursor: pointer;
}
.btn:hover:before{
transform: translateX(300px) skewX(-15deg);
opacity: 0.6;
transition: 0.7s;
}
.btn:hover:after{
transform: translateX(300px) skewX(-15deg);
opacity: 1;
transition: 0.7s;
}
/**Footer**/
.footer{
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #000;
color: #fff;
text-align: left;
font-size: 8px;
}
#game-title{
width: 130px;
height: 40px;
position: absolute;
top: 91%;
left: 50%;
transform: translate(-50%,-50%);
}
#forget{
text-decoration: none;
position: absolute;
top: 110%;
left: 50%;
transform: translate(-50%, -50%);
color: #ffbd04;
font-size: 12px;
font-family: sans-serif;
}
#reg{
text-decoration: none;
position: absolute;
top: 110%;
left: 50%;
transform: translate(-50%, -190%);
color: #ffbd04;
font-size: 12px;
font-family: sans-serif;
}
Sorry long post and thank you in advance.
The approach is wrong sir. It's child element's default behavior. You can't set opacity:1 to the child element once you set it to the parent element.
You have so many ways to achieve this. But since you are using a background color and looking for the opacity I suggest the easiest way that use background:rgba(0,0,0,0.5).This stands that the background color is #333 with the opacity of 0.5.
Learn more about rgba() here.
#container{
/*opacity: 0.5;*/ //remove this line
margin: 0 auto;
padding: 0 auto;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 380px;
height: 480px;
/*background: #000;*/ //remove this line
border: 4px solid #ffbd04;
border-radius: 20px;
background:(0,0,0,0.5); //newly added line
}
You have given opacity:0.5 to container class and opacity:1 to child class. Instead of setting opacity to parent class use background color in rgba format to container class and remove opacity
background: rgba(0, 0, 0, 0.5);
If you use opacity to parent class then child class does not have effect even if you set high opacity to child.
I was able to get some result by using the !important keyword.
#login-box{
opacity: 1 !important;
width: 280px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background: #fff !important;
}
You can't see the text, but you might able to get what you want from there.
How do I display "Confirm Password" in a single line ?
I add an <span id="confirm">Confirm Password</span> and I did this, doesn't work:
#confirm {
display: inline;
}
* {
margin: 0px;
padding: 0px;
}
body {
background-color: Royalblue; /*#f0f0f0;*/
}
.head {
text-align: center;
border: 1px solid #B0C4DE;
border-bottom: none;
border-radius: 10px 10px 0px 0px;
padding: 20px;
background: rgba(0, 250, 0, 0);
color: #FFFACD;
font-family: 'Cinzel', sans-serif;
font-size:30px;
}
.content {
position:relative;
top:8px;
width: 30%;
margin: 50px
auto 0px;
}
form {
position: relative;
margin-top: 0;
margin-left: 0;
width: 89%;
height: 300px;
padding: 20px;
border: 1px solid #B0C4DE;
background: rgba(0, 250, 0, 0);
border-radius: 0px 0px 10px 10px;
}
label {
position: relative;
font-family: 'Montserrat', sans-serif;
font-size: 14px;
z-index: -1;
border: 0;
color: white;
left: -65%;
top: -30px;
}
.username {
position: relative;
top: 65px;
}
.password {
position: relative;
top: 130px;
}
.con-pass {
position: relative;
top: 195px;
}
#confirm {
display: inline;
}
input {
position: absolute;
font-family: 'Montserrat', sans-serif;
border: 0;
border-bottom: 2px solid beige;
background: transparent;
font-size: 15px; /*BORDER yes/no*/
height: 25px;
width: 250px;
outline: 0;
z-index: 1;
left: -74px;
top: -30px;
}
span {
position: absolute;
top: 5px;
left: -6px;
transition: top .5s ease, font-size .5s ease;
}
input:focus + label > span,
input:valid + label > span {
top: -20px;
font-size: 11px;
/* padding-bottom: 15px;*/
}
label::after {
content: '';
position: absolute;
top: 27px; /* ::after position */
left: -7px;
width: 250px;
height: 23px;
border-radius: 2px;
transition: transform .3s;
}
label::after {
z-index: -1;
background: beige; /*#a86bf;*/
transform: scale3d(1, 0, 1);
transform-origin: top;
}
input:focus + label::after,
input:valid + label::after {
transform: scale3d(1, -1.3, 1);
transition-timing-function: linear;
top: 27px; /* ::after position */
}
input:focus {
border-radius: 2px;
}
<div class="content">
<p class="head">Register</p>
<form>
<div class="content">
<div class="email">
<input type="text" id="email" required /> <!--input field-->
<label for="email"><span>Email</span></label>
</div>
<div class="username">
<input type="text" id="user" required />
<label for="user"><span>Username</span></label>
</div>
<div class="password">
<input type="text" id="pass" required /> <!--input field-->
<label for="pass"><span>Password</span></label>
</div>
<div class="con-pass">
<input type="text" id="c-pass" required />
<label for="c-pass"><span id="confirm">Confirm Password</span></label>
</div>
</div>
</form>
</div>
You can use white-space: nowrap; for that :
#confirm {
white-space: nowrap;
}
Here is a resource for the white-space property in CSS.
Use white-space: nowrap; for class con-pass
You can also insert a in your html. That will ensure the two Words are kept on the same line:
<label for="c-pass"><span id="confirm">Confirm Password</span></label>
Below is code to a hamburger menu which I got from a Github Gist. What I want to know is why is the last bar's height not changing and how can I add rounded corners on the bars? Oh, and how can I change the height between the bars? If anyone else has CSS to a single div hamburger menu with those features, let me know.
.hamburger {
display: block;
position: absolute;
top: .5em;
right: .5em;
height: 2.5em;
width: 2.5em;
border: .8em solid rgba(0,133,255,1);
box-shadow: 0 0 0 .1em rgba(255,255,255,0),
inset 0 .3em 0 0 rgba(255,255,255,1),
inset 0 1em 0 0 rgba(0,133,255,1),
inset 0 1.3em 0 0 rgba(255,255,255,1),
inset 0 2em 0 0 rgba(0,133,250,1),
inset 0 2.5em 0 0 rgba(255,255,255,1);
}
<div class="hamburger"></div>
Here's one for you. You can adjust the roundness, thickness and color as you wish.
.menu {
position: relative;
display: inline-block;
width: 30px;
height: 5px;
top: 0px;
border-radius: 5px;
background: #000;
margin: 0;
}
.menu::before {
content: "";
position: absolute;
top: 10px;
left: 0px;
width: 30px;
height: 5px;
border-radius: 5px;
background: #000;
}
.menu::after {
content: "";
position: absolute;
top: 20px;
left: 0px;
width: 30px;
height: 5px;
border-radius: 5px;
background: #000;
}
<div class="menu"></div>
I had this one originally animate to a cross. Without animation you can reduce the code.
Creating the lines with box-shadow will prevent you from rounding them.
You may use pseudo-elements instead
.hamburger-menu
{
width:30px;
height:5px;
background-color:#111;
border-radius:5px;
position:relative;
}
.hamburger-menu:after, .hamburger-menu:before
{
content: '';
width: 100%;
height:5px;
background-color:#111;
position:absolute;
border-radius:5px;
}
.hamburger-menu:after
{
top:10px;
}
.hamburger-menu:before
{
top:20px;
}
<div class="hamburger-menu"> </div>
With the box-shadow method there's no way to add a border-radius, however this is other approach (Close hover is a plus ;) )
*,
*:after,
*:before {
margin: 0;
padding: 0;
-webkit-box-sizing: inherit;
box-sizing: inherit;
-webkit-transition: all ease 0.3s;
transition: all ease 0.3s;
}
*:hover,
*:after:hover,
*:before:hover {
-webkit-transition: all ease 0.3s;
transition: all ease 0.3s;
}
.right {
background: #000;
padding: 10px;
}
.right .bar {
width: 40px;
margin: auto;
border-radius: 2px;
height: 8px;
margin-top: 5px;
display: block;
background: #fff;
}
.right:hover .container-bar {
-webkit-transform: translateX(10px);
transform: translateX(10px);
}
.right:hover .bar {
width: 40px;
margin: auto;
height: 8px;
margin-top: 5px;
display: block;
background: #fff;
}
.right:hover .bar:nth-child(1) {
-webkit-transform-origin: left top;
transform-origin: left top;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.right:hover .bar:nth-child(2) {
opacity: 0;
}
.right:hover .bar:nth-child(3) {
-webkit-transform-origin: left bottom;
transform-origin: left bottom;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
<div class="right triggerMenu">
<div class="container-bar">
<a href="javascript:void(0);">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</a>
</div>
</div>