I used ngx-print to print a section of my page. In that section, there is toggle button (switche) in two places. Both of them get updated using the same ngmodel. In the page, it's getting updated, but when I print it(used Microsoft print to pdf), it's stuck in the first change I did. ex:- If I turn on the button and then turn it off,then hit print, the button in the printed pdf is always turned off. Below is just how the buttons and the layout is used.
input {
display: none;
}
.toggle {
position: relative;
cursor: pointer;
}
.toggle:before {
content: "";
display: block;
width: 26px;
height: 10px;
border-radius: 15px;
background-color: #b0aeae;
}
.toggle span {
position: absolute;
top: -4px;
left: -1px;
width: 16px;
height: 16px;
border-radius: 50%;
background-color: #fafafa;
box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px rgba(0, 0, 0, 0.14), 0px 1px 3px rgba(0, 0, 0, 0.12);
transition: all 0.3s ease;
}
.toggle span .fas {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
color: white;
}
.checkbox:checked + .toggle:before {
background: #51a3f5;
}
.checkbox:checked + .toggle span {
left: -24px;
transform: translateX(35px);
background: #1976d2;
box-shadow: 0px 2px 1px -1px rgba(0, 0, 0, 0.2), 0px 1px 1px rgba(0, 0, 0, 0.14), 0px 1px 3px rgba(0, 0, 0, 0.12);
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx"
crossorigin="anonymous" />
<!--Section that we use-->
<div class="switch-with-text d-flex align-items-center">
<input
type="checkbox"
id="checkbox1"
class="checkbox"
formControlName="stopSmoking"
[(ngModel)]="isChecked_stopSmoking"
(change)="recalculateScore('smoking',$event)"
/>
<label for="checkbox1" class="toggle">
<span>
<i class="fas"></i>
<i class="fas"></i>
</span>
</label>
<p>Stop smoking</p>
</div>
<!--Section that is getting printed-->
<div class="switch-with-text d-flex align-items-center" id="pdf">
<input
type="checkbox"
id="pdf_checkbox1"
class="checkbox"
[(ngModel)]="isChecked_stopSmoking"
/>
<label for="pdf_checkbox1" class="toggle">
<span>
<i class="fas"></i>
<i class="fas"></i>
</span>
</label>
<p class="switch-text">Stop smoking</p>
</div>
<button
class="btn btn-primary"
printSectionId="pdf"
ngxPrint
[useExistingCss]="true"
styleSheetFile="assets/css/print.css"
PrintWithCustomCss
>PRINT</button>
How do I fix this issue?
Related
I have an issue with my radio input.
It lets me change to the second option if im clicking on the label but it doesnt work for the first option. I can only choose the first option if im clicking on the selection-circle but i dont want to display it. It should work with a click on the text.
Any ideas?
.switch-field {
display: flex;
margin-bottom: 36px;
overflow: hidden;
justify-content: center;
}
.switch-field input {
position: absolute;
clip: rect(0, 0, 0, 0);
height: 100px;
width: 100px;
border: 1px;
/* overflow: hidden; */
}
.switch-field label {
background-color: #e4e4e4;
color: rgba(0, 0, 0, 0.6);
font-size: 14px;
line-height: 1;
text-align: center;
padding: 8px 10%;
margin-right: -1px;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
transition: all 0.1s ease-in-out;
}
.switch-field label:hover {
cursor: pointer;
}
.switch-field input:checked+label {
background-color: #cc7676;
box-shadow: none;
}
.switch-field label:first-of-type {
border-radius: 4px 0 0 4px;
}
.switch-field label:last-of-type {
border-radius: 0 4px 4px 0;
}
<div class="switch-field">
<input type="radio" id="strang1u3" name="switch-one" onchange="speichern(); clicksound()" />
<label for="strang1u2">Strang 1 & 3</label>
<input type="radio" id="strang2u4" name="switch-one" onchange="speichern(); clicksound()" />
<label for="strang2u4">Strang 2 & 4</label>
</div>
Your first label's for (strang1u2) and input's id (strang1u3) don't match. This may be causing this as the label isn't associated with the input.
i want create a functionality where i can upload a photo by clicking on the camera icon. Basically i want to do the same thing as when you click a button to choose a file you wanna upload, but i´m not finding a way to do that in the moment.
The html that i used to place the things
<div class="user-sidebar ">
<div class="profile-pic">
<img src="/img/pic.png" alt="" class="pic">
<form action="">
<input type="file" name="pic" accept="image/*">
<i class="fas fa-camera fa-2x"></i>
</form>
</div>
</div>
CSS related to the html
.user-sidebar {
width: 30vw;
height: 100vh;
box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;
background-color: var(--white2);
}
.profile-pic {
margin: 100px auto 0px auto;
height: 170px;
width: 170px;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px;
overflow-y: hidden;
}
.profile-pic i {
position: absolute;
top: 230px;
left: 270px;
cursor: pointer;
color: var(--white);
}
I have added your solution click on icon for upload image .
.image-upload {
height: 170px;
width: 170px;
border-radius: 50%;
box-shadow: rgb(0 0 0 / 16%) 0px 3px 6px, rgb(0 0 0 / 23%) 0px 3px 6px;
margin: 100px auto 0px auto;
overflow-y: hidden;
}
.image-upload > input
{
display: none;
}
.image-upload img
{ width: 80px;
cursor: pointer;
position: absolute;
top: 212px;
left: 330px;
color: var(--white);
}
<div>Click the upload icon below to upload a file.</div>
<div class="image-upload">
<label for="file-input">
<img src="https://image.flaticon.com/icons/png/512/70/70310.png"/>
</label>
<input id="file-input" type="file"/>
</div>
Here is the solution, please change the classes name as you need and also the image path
Html
<div>Click the upload icon below to upload a file.</div>
<div class="image-upload">
<label for="file-input">
<img src="icons/mixed-12/130/188-512.png"/>
</label>
<input id="file-input" type="file"/>
</div>
Css
.image-upload {
height: 170px;
width: 170px;
border-radius: 50%;
box-shadow: rgb(0 0 0 / 16%) 0px 3px 6px, rgb(0 0 0 / 23%) 0px 3px 6px;
margin: 100px auto 0px auto;
overflow-y: hidden;
}
.image-upload > input
{
display: none;
}
.image-upload img
{ width: 80px;
cursor: pointer;
position: absolute;
top: 212px;
left: 630px;
color: var(--white);
}
I got a custom HTML-object and every way I tried to center the class, it failed. Does anybody have an idea? Kind regards.
I tried . Other objects ere centered, only this one wasn't. I tried margin: 0px auto. I tried . My custom object keeps left-aligned. I think there could be an attribute
.switch-mode {
display: flex;
margin-bottom: 36px;
overflow: hidden;
}
.switch-mode input {
position: absolute !important;
clip: rect(0, 0, 0, 0);
height: 1px;
width: 1px;
border: 0;
overflow: hidden;
}
.switch-mode label {
background-color: #e4e4e4;
color: rgba(0, 0, 0, 0.6);
font-size: 14px;
line-height: 1;
text-align: center;
padding: 8px 16px;
margin-right: -1px;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
transition: all 0.1s ease-in-out;
}
.switch-mode label:hover {
cursor: pointer;
}
.switch-mode input:checked+label {
background-color: #C23434;
box-shadow: none;
}
.switch-mode label:first-of-type {
border-radius: 4px 0 0 4px;
}
.switch-mode label:last-of-type {
border-radius: 0 4px 4px 0;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="switch-mode">
<input type="radio" id="radio-open" name="mode" />
<label for="radio-open">OPEN</label>
<input type="radio" id="radio-auto" name="mode" />
<label for="radio-auto">AUTO</label>
<input type="radio" id="radio-close" name="mode" />
<label for="radio-close">CLOSE</label>
</div>
</body>
</html>
Your container is what needs to be centered, not the items within it. The addition is justify-content: center; within the .switch-mode class.
.switch-mode {
display: flex;
margin-bottom: 36px;
overflow: hidden;
justify-content: center;
}
.switch-mode input {
position: absolute !important;
clip: rect(0, 0, 0, 0);
height: 1px;
width: 1px;
border: 0;
overflow: hidden;
}
.switch-mode label {
background-color: #e4e4e4;
color: rgba(0, 0, 0, 0.6);
font-size: 14px;
line-height: 1;
text-align: center;
padding: 8px 16px;
margin-right: -1px;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
transition: all 0.1s ease-in-out;
}
.switch-mode label:hover {
cursor: pointer;
}
.switch-mode input:checked+label {
background-color: #C23434;
box-shadow: none;
}
.switch-mode label:first-of-type {
border-radius: 4px 0 0 4px;
}
.switch-mode label:last-of-type {
border-radius: 0 4px 4px 0;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="switch-mode">
<input type="radio" id="radio-open" name="mode" />
<label for="radio-open">OPEN</label>
<input type="radio" id="radio-auto" name="mode" />
<label for="radio-auto">AUTO</label>
<input type="radio" id="radio-close" name="mode" />
<label for="radio-close">CLOSE</label>
</div>
</body>
</html>
On .switch-mode, you have used flex layout. So add justify-content: center on .switch-mode class and it will be aligned on center position.
.switch-mode {
display: flex;
margin-bottom: 36px;
overflow: hidden;
justify-content: center;
}
.switch-mode input {
position: absolute !important;
clip: rect(0, 0, 0, 0);
height: 1px;
width: 1px;
border: 0;
overflow: hidden;
}
.switch-mode label {
background-color: #e4e4e4;
color: rgba(0, 0, 0, 0.6);
font-size: 14px;
line-height: 1;
text-align: center;
padding: 8px 16px;
margin-right: -1px;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
transition: all 0.1s ease-in-out;
}
.switch-mode label:hover {
cursor: pointer;
}
.switch-mode input:checked+label {
background-color: #C23434;
box-shadow: none;
}
.switch-mode label:first-of-type {
border-radius: 4px 0 0 4px;
}
.switch-mode label:last-of-type {
border-radius: 0 4px 4px 0;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="switch-mode">
<input type="radio" id="radio-open" name="mode" />
<label for="radio-open">OPEN</label>
<input type="radio" id="radio-auto" name="mode" />
<label for="radio-auto">AUTO</label>
<input type="radio" id="radio-close" name="mode" />
<label for="radio-close">CLOSE</label>
</div>
</body>
</html>
I have two columns with select and button tag.
I have givn 100% height to both of them.
When I try to resize the screen height of each element is getting changed .
How can I prevent this on resize of screen?
#btn-folder{
width: 100%;
height: 100%;
background-color:rgb(194, 191, 191);
color: white;
padding: 12px 45px;
border: none;
border-radius: 10px;
text-align: center;
cursor: pointer;
font-size:16px;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.16), 0 1px 4px rgba(0, 0, 0, 0.26);
}
#btn-folder:hover{
background-color:rgb(94, 89, 89);
}
.custom-selection{
position:relative;
background-color:white;
border-radius: 10px;
height: 100%;
}
.custom-selection select {
display: block;
border:none;
background-color:white;
color: blue;
padding: 10px;
width: 100%;
height: 100%;
border-radius: 10px;
font-size: 20px;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.16), 0 1px 4px rgba(0, 0, 0, 0.26);
margin: 0;
-webkit-appearance: none;
-moz-appearance: none;
position:relative;
z-index:2;
background:transparent;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" crossorigin="anonymous">
<div class="container-fluid ">
<div class="row dropdown">
<div class="col-sm-9 ">
<div class="custom-selection">
<select class="round" id="myselect">
</select>
</div>
</div>
<div class="col-sm-3 folder-btn">
<button id="btn-folder" class="btn btn-light"> Open Folder</button>
</div>
</div>
</div>
I can't find a way to make the checkboxes checked in IE8. It's based on a Google Form, I re-used the same code to easily have an answer sheet. On top of that, the answers aren't sent.
I use this code
<li class="ss-choice-item">
<label>
<span class="ss-choice-item-control goog-inline-block">
<input type="checkbox" name="entry.637692828" value="Facebook" id="group_637692828_2" role="checkbox" class="ss-q-checkbox">
<label for="group_637692828_2"></label>
</span>
<span class="ss-choice-label">Facebook</span>
</label>
</li>
Here is the CSS, I wanted to custom the buttons, it works really fine in all other browsers.
.ss-q-checkbox {
display: none;
}
.ss-q-checkbox + label {
background-color: #fafafa;
border: 1px solid #cacece;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05);
padding: 9px;
border-radius: 3px;
display: inline-block;
position: relative;
margin-right: 4px;
}
.ss-q-checkbox + label:active, .ss-q-checkbox:checked + label:active {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0px 1px 3px rgba(0, 0, 0, 0.1);
}
.ss-q-checkbox:checked + label {
background-color: #e9ecee;
border: 1px solid #adb8c0;
color: #f87000;
}
.ss-q-checkbox:checked + label:after {
content:'\2714';
font-size: 14px;
position: absolute;
top: 0px;
left: 3px;
color: #f87000;
}
Could someone have the solution?
Thanks :)
You cannot use display:none (or visibility:hidden) on inputs with IE8 as it will treat it as if the input isn't there. Instead of hiding it using display try the following:
.ss-q-checkbox {
position:fixed; left:100%; top:0;
}