How can I display the checkbox over the images for selection? - html

I want to display a checkbox for selection on the right bottom of every image..
How can i do something like this?
Please remember that clicking on image has a unique event(that i'll manage to do!) , but clicking on that check box should select/deselect that one?

This can be done with pure CSS, assuming you have fixed width and height for all images. The trick is setting absolute position for the checkbox then assign bottom and right to zero.
HTML sample:
<div class="container">
<img src="image1.jpg" />
<input type="checkbox" class="checkbox" id="check1" />
</div>
<div class="container">
<img src="image2.jpg" />
<input type="checkbox" class="checkbox" id="check2" />
</div>
CSS:
.container { position: relative; width: 100px; height: 100px; float: left; margin-left: 10px; }
.checkbox { position: absolute; bottom: 0px; right: 0px; }
Live test case.
As for click events, just apply click handler to each checkbox and it will work just fine.. see in this updated fiddle.

You can use a "label" tag that contains an "img" tag inside.
Here's an example of using an image as a checkbox and radio.
* {
font-family: Lato;
margin: 0;
padding: 0;
--transition: 0.15s;
--border-radius: 0.5rem;
--background: #ffc107;
--box-shadow: #ffc107;
}
.cont-bg {
min-height: 100vh;
background-image: radial-gradient(
circle farthest-corner at 7.2% 13.6%,
rgba(37, 249, 245, 1) 0%,
rgba(8, 70, 218, 1) 90%
);
padding: 1rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.cont-title {
color: white;
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 1rem;
}
.cont-main {
display: flex;
flex-wrap: wrap;
align-content: center;
justify-content: center;
}
.cont-checkbox {
width: 150px;
height: 100px;
border-radius: var(--border-radius);
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
background: white;
transition: transform var(--transition);
}
.cont-checkbox:first-of-type {
margin-bottom: 0.75rem;
margin-right: 0.75rem;
}
.cont-checkbox:active {
transform: scale(0.9);
}
input {
display: none;
}
input:checked + label {
opacity: 1;
box-shadow: 0 0 0 3px var(--background);
}
input:checked + label img {
-webkit-filter: none; /* Safari 6.0 - 9.0 */
filter: none;
}
input:checked + label .cover-checkbox {
opacity: 1;
transform: scale(1);
}
input:checked + label .cover-checkbox svg {
stroke-dashoffset: 0;
}
label {
display: inline-block;
cursor: pointer;
border-radius: var(--border-radius);
overflow: hidden;
width: 100%;
height: 100%;
position: relative;
opacity: 0.6;
}
label img {
width: 100%;
height: 70%;
object-fit: cover;
clip-path: polygon(0% 0%, 100% 0, 100% 81%, 50% 100%, 0 81%);
-webkit-filter: grayscale(100%); /* Safari 6.0 - 9.0 */
filter: grayscale(100%);
}
label .cover-checkbox {
position: absolute;
right: 5px;
top: 3px;
z-index: 1;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--box-shadow);
border: 2px solid #fff;
transition: transform var(--transition),
opacity calc(var(--transition) * 1.2) linear;
opacity: 0;
transform: scale(0);
}
label .cover-checkbox svg {
width: 13px;
height: 11px;
display: inline-block;
vertical-align: top;
fill: none;
margin: 5px 0 0 3px;
stroke: #fff;
stroke-width: 2;
stroke-linecap: round;
stroke-linejoin: round;
stroke-dasharray: 16px;
transition: stroke-dashoffset 0.4s ease var(--transition);
stroke-dashoffset: 16px;
}
label .info {
text-align: center;
margin-top: 0.2rem;
font-weight: 600;
font-size: 0.8rem;
}
<div class="cont-bg">
<div class="cont-title">Checkbox</div>
<div class="cont-main">
<div class="cont-checkbox">
<input type="checkbox" id="myCheckbox-1" />
<label for="myCheckbox-1">
<img
src="https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/2021-mazda-mx-5-miata-mmp-1-1593459650.jpg?crop=0.781xw:0.739xh;0.109xw,0.0968xh&resize=480:*"
/>
<span class="cover-checkbox">
<svg viewBox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<div class="info">Mazda MX-5 Miata</div>
</label>
</div>
<div class="cont-checkbox">
<input type="checkbox" id="myCheckbox-2" />
<label for="myCheckbox-2">
<img
src="https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/2020-chevrolet-corvette-c8-102-1571146873.jpg?crop=0.548xw:0.411xh;0.255xw,0.321xh&resize=980:*"
/>
<span class="cover-checkbox">
<svg viewBox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<div class="info">Toyota Supra</div>
</label>
</div>
</div>
<div class="cont-title">Radio</div>
<div class="cont-main">
<div class="cont-checkbox">
<input type="radio" name="myRadio" id="myRadio-1" />
<label for="myRadio-1">
<img
src="https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/2021-mazda-mx-5-miata-mmp-1-1593459650.jpg?crop=0.781xw:0.739xh;0.109xw,0.0968xh&resize=480:*"
/>
<span class="cover-checkbox">
<svg viewBox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<div class="info">Mazda MX-5 Miata</div>
</label>
</div>
<div class="cont-checkbox">
<input type="radio" name="myRadio" id="myRadio-2" />
<label for="myRadio-2">
<img
src="https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/2020-chevrolet-corvette-c8-102-1571146873.jpg?crop=0.548xw:0.411xh;0.255xw,0.321xh&resize=980:*"
/>
<span class="cover-checkbox">
<svg viewBox="0 0 12 10">
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
</svg>
</span>
<div class="info">Toyota Supra</div>
</label>
</div>
</div>
</div>

If only selecting/dis-selecting of the checkbox is your requirement then What I would suggest is as under :
Step 1: Place the image and the checkbox inside a block (may it be a div or table)
Step 2: Provide that block relative position with some specific height and width.
Step 3: For checkbox, give it absolute position and set the right and bottom gaps (based on your requirement).
For instance, the code should look like this
<div class="img_block">
<img src="image-path" alt="" />
<input type="checkbox" class="chkbox" />
</div>
<div class="img_block">
<img src="image-path" alt="" />
<input type="checkbox" class="chkbox" />
</div>
And the css for the same is
.img_block {position:relative; width:230px; margin-right:20px; margin-bottom:10px; height:30px;}
.chkbox {position:absolute; right:5px; bottom:3px;}
I hope this suits your requirement.

If it were me I would try usign jQuery for this.Lets pretend that each image is in each own div and the checkbo has an id of check:
$('div').click(function()
{
//you select the checkbox and ad the code to do what you want to it
('#check').
});

Related

Footer is not end of page when zooming out

since i am learning CSS i am playing around a little, and i ran into this weird issue where the footer is not the end of the page.
Currently my Footer is like this:
If i move the whole div into the footer div, it doesn't show the full content since the footer sticks to the page, so i moved it above to be able to scroll the content, which works fine so far, however, as soon as i zoom out it creates more background below the footer.
html, body {
max-width: 100%;
max-height: 100%;
height: 100%;
overflow-x: visible;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
margin: 0;
background-color: #666666;
}
/* Style for the navigation */
.topnav {
overflow: hidden;
background-color: #333;
}
/* Style the navigation links */
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 1.3rem 1.3rem;
text-decoration: none;
font-weight: bold;
}
/* Change color on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a:not(.active){
padding-bottom: (1.3rem + 6px);
}
.topnav .active:after{
border: 10px solid transparent;
border-bottom-color: #cd650b;
border-top-width: 0;
content: "";
display: block;
z-index: 101;
margin: 0 auto;
width: 0px;
margin-top: 11px;
margin-bottom: -21px;
}
.TopnavSecondBar {
height: 40px;
background-color: #cd650b;
min-width: 100%;
max-width: 100%;
margin: auto;
z-index: 10;
}
/* Triangle Shapes Start*/
.shapes {
position: 50px 50px 50px 50px;
background-color: #cd650b;
}
.boxesFooterBoxesBefore .st0, .boxesFooterBoxesAfter .st0 {
fill: #cd650b;
bottom: 0;
right: 0;
}
*, ::before, ::after {
box-sizing: inherit;
min-width: 0;
}
.boxesFooterBoxes {
color: #eee;
}
/* Content style */
.content {
/* background-color: #d9d9d9; */
padding: 10px;
height: 200px;
}
.button1 {
background-color: #333;
color: white;
padding: 0.5rem;
font-family: Arial, Helvetica, sans-serif;
border-style: hidden;
cursor: pointer;
margin-top: 1rem;
}
.button2 {
text-decoration: none;
background-color: #333;
color: white;
padding: 0.5rem;
font-family: Arial, Helvetica, sans-serif;
border-style: hidden;
cursor: pointer;
margin-top: 1rem;
}
.button2:disabled{
background-color: grey;
color: white;
padding: 0.5rem;
font-family: Arial, Helvetica, sans-serif;
border-style: hidden;
cursor: pointer;
margin-top: 1rem;
}
/* Center Buttons */
.center {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
/* Footer */
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: transparent;
color: white;
text-align: center;
}
.footerLinks:link, .footerLinks:visited {
background-color: #333;
color: white;
padding: 0.2rem;
text-align: center;
text-decoration: none;
display: inline-block;
margin-top: 0.452125rem;
margin-bottom: 0.1rem;
margin-left: 0.5rem;
margin-right: 0.5rem;
}
.footerLinks:hover, .footerLinks:active {
background-color: #d9d9d9;
color: black;
}
.copyright {
margin-top: 1px;
font-size: .9525rem
}
/* Javascript message style */
.js{
white-space: nowrap;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.converter {
margin: 0;
position: absolute;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.boxesFooterBoxesAfter {
width: 101%;
z-index: 1;
height: 60px;
position: relative;
margin-top: 0px;
margin-bottom: 2rem;
}
.BottomNavSecondBar {
height: 40px;
background-color: #cd650b;
min-width: 100%;
max-width: 100%;
margin: 0px auto auto auto;
z-index: 10;
}
.BottomNavThirdBar {
height: 65.2125px;
background-color: #333;
min-width: 100%;
max-width: 100%;
margin: 0px auto auto auto;
z-index: 10;
text-align: center;
}
.AdditionalPartnerBefore, .st2 {
width: 100%;
height: -50px;
position: relative;
margin-bottom: -4px;
}
.codebox {
resize: none;
border-style: solid;
}
/* Display button above text */
/*.btn i {
display: block;
} */
.btn {
width: 8.4rem;
display: inline-block;
background-color: #333;
border: none;
color: white;
padding: 1.7rem;
margin: 0.3rem;
font-size: 17px;
cursor: pointer;
border: solid;
border-color: #cd650b;
border-width: 1px;
}
/* Darker background on mouse-over */
.btn:hover {
background-color: #ddd;
color: black;
border-color: #cd650b;
border-width: 1px;
}
.flex-container {
display: flex;
background-color: transparent;
flex-direction: row;
flex: auto;
}
.flex-container > div {
background-color: transparent;
margin: 20rem;
padding: 20px;
font-size: 30px;
}
.flex-container {
display: flex;
flex-wrap: wrap;
text-align: center;
justify-content: center;
}
.btn {
max-width: 30%;
margin: 5px;
}
.schmutz {
.footer {
display: flex;
background-color: #000;
color: #fff;
height: 170px;
width: 100%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" type="image/jpg" href="./images/favicon.jpg"> <!--favicon-->
<link rel="stylesheet" href="./styles.css" type="text/css">
<link rel="stylesheet" href="./button.css" type="text/css">
<link rel="stylesheet" href="./math.css" type="text/css">
<script src="https://kit.fontawesome.com/763deb09da.js" crossorigin="anonymous"></script>
<meta charset="UTF-8"> <!--UTF8 charset-->
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1"> <!--responsive-->
<title>Schmutz</title> <!--page title-->
</head>
<body>
<noscript id="noscript" class="noscript"> <!-- if Javascript is disabled -->
<meta HTTP-EQUIV="refresh" content=0;url="nojs.php">
</noscript> <!-- redirect to nojs site -->
<div class="topnav">
<b>Home</b>
<a class="active" href="./configurator.php"><b>Configurator</b></a>
<b>Trader</b>
<a target="_blank" rel="noopener noreferrer" href="https://scum-forum.com/"><b>Forum</b></a>
</div>
<div class="TopnavSecondBar"></div>
<div class="pageNavigationAfter">
<svg version="1.1" preserveAspectRatio="none" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1920 80" style="enable-background:new 0 0 1920 80;" xml:space="preserve">
<g transform="translate(0.000000,80.000000) scale(0.100000,-0.100000)">
<path fill="#333" class="st1" d="M0 400 l0 -400 88 1 c48 0 4369 179 9602 398 l9515 399 -9602 1 -9603 1 0 -400z"></path>
</g>
</svg>
</div>
<div class="flex-container">
<button class="btn"><i class="fa fa-wrench"></i> Basics</button>
<button class="btn"><i class="fa fa-car"></i> Vehicle</button>
<button class="btn"><i class="fa fa-dolly"></i> Items</button>
<button class="btn"><i class="fa fa-download"></i> Config</button>
</div>
<hr>
<div class="wrapper">
<div class="a">
<label class="switch">
<input type="checkbox">
<span class="slider"></span>
</label> testtesttesttest
<div class="b">
<label class="test" for="quantity">economy-reset-time-hours</label>
<input class="number" type="number" id="quantity" name="quantity" min="-1" max="100">
<label for="quantity"></label>
</div>
<div class="b">
<label class="test" for="quantity">e</label>
<input class="number" type="number" id="quantity" name="quantity" min="-1" max="100">
<label for="quantity">testtesttesttesttesttest</label>
</div>
<div class="b">
<label class="test" for="quantity">e</label>
<input class="number" type="number" id="quantity" name="quantity" min="-1" max="100">
<label for="quantity">testtesttesttesttesttest</label>
</div>
<div class="b">
<label class="test" for="quantity">e</label>
<input class="number" type="number" id="quantity" name="quantity" min="-1" max="100">
<label for="quantity">testtesttesttesttesttest</label>
</div>
<div class="b">
<label class="test" for="quantity">e</label>
<input class="number" type="number" id="quantity" name="quantity" min="-1" max="100">
<label for="quantity">testtesttesttesttesttest</label>
</div>
<div class="b">
<label class="test" for="quantity">e</label>
<input class="number" type="number" id="quantity" name="quantity" min="-1" max="100">
<label for="quantity">testtesttesttesttesttest</label>
</div>
<div class="b">
<label class="test" for="quantity">e</label>
<input class="number" type="number" id="quantity" name="quantity" min="-1" max="100">
<label for="quantity">testtesttesttesttesttest</label>
</div>
<div class="b">
<label class="test" for="quantity">e</label>
<input class="number" type="number" id="quantity" name="quantity" min="-1" max="100">
<label for="quantity">testtesttesttesttesttest</label>
</div>
<div class="b">
<label class="test" for="quantity">e</label>
<input class="number" type="number" id="quantity" name="quantity" min="-1" max="100">
<label for="quantity">testtesttesttesttesttest</label>
</div>
</div>
</div>
<div class="schmutz">
<div class="AdditionalPartnerBefore">
<svg version="1.1" preserveAspectRatio="none" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1920 80" style="max-width:100%; enable-background:new 0 0 1920 80;" xml:space="preserve">
<!-- <svg version="1.1" preserveAspectRatio="none" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="5rem" style="max-width:100%; enable-background:new 0 0 1920 80;" xml:space="preserve"> -->
<g transform="translate(0.000000,80.000000) scale(0.100000,-0.100000)">
<path fill="#333" class="st2" d="M9480 400 l-9485 -398 9603 -1 9602 -1 0 400 0 400 -117 -1 c-65 -1 -4386 -180 -9603 -399z"></path>
</g>
</svg>
</div>
<div class="BottomNavSecondBar"></div>
<div class="BottomNavThirdBar">
<a class="footerLinks" href="https://scum-forum.com/core/legal-notice/">Legal Notice</a>
<a class="footerLinks" href="https://scum-forum.com/core/privacy-policy/">Privacy Policy</a>
<p class="copyright">© test-test.com<p>
</div>
<div class="footer"></div>
</body>
</html>
You can use flex-box to achieve a footer that stays at the bottom of the browser window when there isn't sufficient content to push it down. When there is sufficient content, the footer will be in a natural flow with the other elements and the page (including footer) will scroll as expected.
You can see how this works in this CodePen. (In the future, creating a minimal reproducible example in something like CodePen can help people debug your issue faster. You'll need to strip away as much as possible from your code so that only the essential parts that cause the issue remain.) I've marked the parts relevant to you, but, in summary:
Set the CSS properties of display: flex; flex-direction: column; min-height: 100vh; on your body (or another element that wraps around your nav, main content, and footer)
Wrap your main content in a wrapping container, like main and apply flex-grow: 1

Firefox flexbox space-between bug - item is out of the container

I created a simple component and when I created a flex container, items inside (for example suffix) are out the box, but only in Firefox. I use space-between in flex item, but item is out of the flex container. It works when I set height with of the Input, but that's what I don't want.
I created a CodePen here, because I can't use Sass here in a Stack Snippet.
Does anybody knows about this?
CodePen: https://codepen.io/ondrejko/pen/wvageWg
// Component local variables
$input-border-color: #D8DADC;
$input-border-disabled-color: #E8EAEC;
$input-text-gray: #979797;
$input-text-color: #457CCC;
$input-focus-color: #0284FF;
$input-border-radius: 8px;
$input-font-size: 16px;
$input-height: 40px;
// Base structure
.Input {
position: relative;
max-width: 200px;
}
// Input container for all elements
.Input__container {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
height: $input-height;
background-color: #fff;
font-size: $input-font-size;
}
// Fake input, who replaces real input and is in front of input
.Input__fake-input {
position: absolute;
z-index: 1;
top: 0px;
left: 0px;
width: 100%;
height: inherit;
border-width: 1px;
border-style: solid;
border-color: $input-border-color;
border-image: none;
border-radius: $input-border-radius;
font-size: $input-font-size;
transition: all 0.15s ease-in-out 0s;
}
// Input text field for add text
.Input__field {
z-index: 2;
flex: 1 1 20%;
width: 100%;
height: 100%;
padding: 0px 12px;
border: 0;
color: $input-text-color;
background-color: transparent;
font-size: inherit;
-webkit-appearance: none;
&:focus {
outline: none;
&~.Input__fake-input {
outline: none;
border: 1px solid $input-focus-color;
}
}
}
// Input type PREFIX
.Input__prefix {
z-index: 3;
display: flex;
height: 100%;
align-items: center;
justify-content: center;
padding: 0px 0px 0px 10px;
color: $input-text-gray;
pointer-events: none;
}
// Input type SUFFIX
.Input__suffix {
z-index: 3;
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
height: 100%;
padding: 0px 10px 0px 0;
color: $input-text-gray;
}
// Input type ICON
.Input__icon {
position: relative;
z-index: 3;
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 48px;
height: calc(100% - 2px);
color: $input-text-gray;
padding: 0px 10px;
border-left: 1px solid $input-border-color;
cursor: pointer;
& img,
svg {
width: 25px;
}
}
// Input type CONTROLS
.Input__controls {
width: 72px;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 0 0 10px;
&+.Input__fake-input {
width: calc(100% - 80px);
}
}
// Input type BUTTON
.Input__button {
width: 32px;
height: 32px;
background: red;
border-radius: 100px;
border: 0;
color: #fff;
padding: 0;
cursor: pointer;
& .Icon {
display: flex;
align-items: center;
justify-content: center;
}
& img,
svg {
max-width: 16px;
}
}
// Modificator --has-status
.Input--has-status {
position: relative;
}
.Input--has-status::after {
content: '';
position: absolute;
top: -4px;
right: -4px;
z-index: 3;
width: 10px;
height: 10px;
border-radius: 100%;
background: #1A73E8;
}
// --has-status types
.Input--has-status.success::after {
background: #37C9AD;
}
.Input--has-status.warning::after {
background: #FFB000;
}
// Modificator --is-invalid
.Input--is-invalid {
& .Input__fake-input {
border: 1px solid #FF0054; // tady barva bude z global variables
}
& .Input__field {
color: #FF0054; // tato barva bude z global variables
&:focus~.Input__fake-input {
border-color: #FF0054; // tady barva bude z global variables
}
}
}
// Modificator --is-disabled
.Input--is-disabled {
& .Input__fake-input {
background-color: $input-border-disabled-color;
color: #868C92;
cursor: not-allowed;
border: 1px solid $input-border-disabled-color;
}
& .Input__field {
color: #868C92;
cursor: not-allowed;
}
}
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,900&display=swap" rel="stylesheet">
<div class="container">
<form>
<div class="row">
<h1> Types</h1>
<h2>Input - default</h2>
<div class="Input">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - prefix</h2>
<div class="Input">
<div class="Input__container">
<div class="Input__prefix">
<span class="Prefix">Prefix</span>
</div>
<input class="Input__field" type="text" placeholder="Placeholder" value="Lorem ipsum dolor">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - suffix</h2>
<div class="Input">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder" value="Lorem ipsum dolor">
<div class="Input__suffix">
Suffix
</div>
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - icon</h2>
<div class="Input">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder">
<div class="Input__icon">
<img src="http://www.ondrejkonecny.cz/assets/svg/calculator.svg">
</div>
<div class="Input__fake-input"></div>
</div>
</div>
<br><br>
<h1>Modificators</h1>
<h2>Input - Load Success</h2>
<div class="Input Input--has-status success">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - Load Warning</h2>
<div class="Input Input--has-status warning">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - Invalid</h2>
<div class="Input Input--is-invalid">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder" value="Lorem ipsum dolor">
<div class="Input__fake-input"></div>
</div>
</div>
<h2>Input - Disabled</h2>
<div class="Input Input--is-disabled">
<div class="Input__container">
<input class="Input__field" type="text" placeholder="Placeholder" value="Lorem ipsum" disabled>
<div class="Input__icon">
<img src="http://www.ondrejkonecny.cz/assets/svg/calendarDay.svg">
</div>
<div class="Input__fake-input"></div>
</div>
</div>
</div>
</form>
</div>
You are using two types of Input types, and you are referring the same CSS classes to achieve (EX .Input.Input__field,.Input__suffix);
one with Prefix,Suffix with Icon (Input box should occupy 75%, Icon should occupy 25%).
Input Modificators. (A default type: Input box should occupy 100%)
Its better you add a class(ex : .default ) to differentiate the input box with Icon and without Icon like above.
I modified code here # code-pen : https://codepen.io/mediraviteja/pen/OJyrozR
Code changes I did below.
a) Added class ".default" to the container div(EX : ) for all the full width inputs like (Default input, Modificator inputs)
b) Do CSS changes in below class
.Input__field{
width: 100%; -- remove css property
max-width: 76%; -- add css property
}
.Input__suffix{
max-width: 26%; -- add css property
}
**Add new class**
.default .Input__field{
max-width: 100%;
}
.default .Input__suffix{
max-width: 100%;
}
change the HTML element
<div class="Input "> to <div class="Input default">
when ever you need full with Input box like(Default input, Input -Warning,Input - Invalid boxes,etc.)

Unable show tick mark on image while clicking an image?

I am trying to show a tick mark on top of the image when a user clicks on it. I have an input radio button element and label both wrapped in anchor element and inside the label i have and an image element and i use css to apply tick mark. Whenever i click on the image nothing happens. Please i would appreciate if anyone can help. Here is the snippets
.icon {
margin: 5px 0;
}
.icon input {
display: none;
}
.icon img {
vertical-align: middle;
width: 50%;
border: 2px solid greenyellow;
}
.icon input:checked {
background: rgba(0,0,0,0.5);
}
.icon input:checked::after{
content: '✔';
position: absolute;
top: 50%;
left: 50%;
width: 30px;
height: 30px;
transform: translate(-50%, -50%);
color: black;
font-size: 20px;
text-align: center;
border: 1px solid black;
border-radius: 50%;
}
<div class="row">
<a href="#" class="col-sm-4 icon">
<input type="radio" name="selimg" id="selimg1">
<label for="selimg1">
<img src="./images/baby-bottle.png">
</label>
</a>
<a href="#" class="col-sm-4 icon">
<input type="radio" name="selimg" id="selimg2">
<label for="selimg2">
<img src="./images/badge.png">
</label>
</a>
<a href="#" class="col-sm-4 icon">
<img src="./images/cardiologist.png">
</a>
</div>
::before and ::after only work on container elements, so you can not use that on your inputs.
Instead of .icon input:checked::after try using .icon input:checked + label::before.
(The rest of your CSS needs adjustments to make it show how you want, but this will at least make it show up and you can move it where it needs to be)
.icon {
margin: 5px 0;
}
.icon input {
display: none;
}
.icon img {
vertical-align: middle;
width: 50%;
border: 2px solid greenyellow;
}
.icon input:checked {
background: rgba(0, 0, 0, 0.5);
}
.icon input:checked + label::before {
content: '✔';
position: absolute;
top: 50%;
left: 50%;
width: 30px;
height: 30px;
transform: translate(-50%, -50%);
color: black;
font-size: 20px;
text-align: center;
border: 1px solid black;
border-radius: 50%;
}
<div class="row">
<a href="#" class="col-sm-4 icon">
<input type="radio" name="selimg" id="selimg1">
<label for="selimg1">
<img src="./images/baby-bottle.png">
</label>
</a>
<a href="#" class="col-sm-4 icon">
<input type="radio" name="selimg" id="selimg2">
<label for="selimg2">
<img src="./images/badge.png">
</label>
</a>
<a href="#" class="col-sm-4 icon">
<img src="./images/cardiologist.png">
</a>
</div>

The CSS image slider overlays the position of the elements

I am coding a simple landing page. In theory, each div you code will show below the previous one and so forth.
I made a little navbar and then expected the slider to appear below it. Then, I wanted to add an image below the slider (the one with brands' logos). Problem is, the image appears below the navbar. I am guessing there is something with the position of the slider but I can't figure out what it is.
I'd rather not use position: absolute or position: relative to position all my elements, so I am here to understand what the problem might be.
html {
font-family: "Arial", Helvetica, sans-serif;
}
/*---navigation--*/
.top-nav {
height: 105px;
display: flex;
align-items: center;
}
ul.main-nav {
display: flex;
align-items: center;
list-style-type: none;
margin: 0;
padding: 0;
background-color: #333;
height: 40px;
}
ul.main-nav li {
display: block;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 15px;
font-weight: 700;
color: #FCAF17;
}
ul.main-nav li:hover {
cursor: pointer;
color: #FFFFFF;
}
/* main slider */
.slider {
width: 100%;
height: 100%;
left: 0;
top: 25%;
opacity: 1;
z-index: 0;
display: flex;
display: -webkit-flex;
display: -ms-flexbox;
flex-flow: row wrap;
-webkit-flex-align: center;
-webkit-align-items: center;
align-items: center;
justify-content: center;
align-content: center;
-webkit-transition: -webkit-transform 1600ms;
transition: -webkit-transform 1600ms, transform 1600ms;
-webkit-transform: scale(1);
transform: scale(1);
}
/* image slider position */
.slide1 {
position: absolute;
left: 0;
}
.slide2 {
position: absolute;
left: 100%;
}
.slide3 {
position: absolute;
left: 200%;
}
/* slider pagination */
.slider-pagination {
position: absolute;
bottom: 20px;
width: 100%;
left: 0;
text-align: center;
z-index: 1000;
}
.slider-pagination label {
width: 10px;
height: 10px;
border-radius: 50%;
display: inline-block;
background: rgba(255, 255, 255, 0.2);
margin: 0 2px;
border: solid 1px rgba(255, 255, 255, 0.4);
cursor: pointer;
}
/* slider control */
input {
visibility: hidden;
}
.slide-radio1:checked~.slider {
-webkit-transform: translateX(0%);
transform: translateX(0%);
}
.slide-radio2:checked~.slider {
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}
.slide-radio3:checked~.slider {
-webkit-transform: translateX(-200%);
transform: translateX(-200%);
}
/*----------slider end----------------*/
.box {
background-color: blue;
}
<!--navigation-->
<div class="top-nav">
<img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/logo.jpg"></img>
</div>
<ul class="main-nav">
<li>HOMBRE</li>
<li>MUJER</li>
<li>NIÑOS</li>
<li>Carrito</li>
</ul>
<!--image slider-->
<div class="css-slider-wrapper">
<input type="radio" name="slider" class="slide-radio1" checked id="slider_1">
<input type="radio" name="slider" class="slide-radio2" id="slider_2">
<input type="radio" name="slider" class="slide-radio3" id="slider_3">
<div class="slider-pagination">
<label for="slider_1" class="page1"></label>
<label for="slider_2" class="page2"></label>
<label for="slider_3" class="page3"></label>
</div>
<div class="slider slide1">
<div>
<img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/racing-980x400.jpg">
</div>
</div>
<div class="slider slide2">
<div>
<img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/evoACCURACY_980x400px.jpg">
</div>
</div>
<div class="slider slide3">
<div>
<img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/racing-980x400.jpg">
</div>
</div>
</div>
<div class="brands">
<img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/marcas.jpg">
</div>
Live demo
first thing you can add Position : relative and second add height to div like i added <div class="demo" style="opacity:0;"> <img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/racing-980x400.jpg"> </div>
<div class="css-slider-wrapper">
<div class="demo" style="opacity:0;"> <img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/racing-980x400.jpg"> </div>
<input name="slider" class="slide-radio1" checked="" id="slider_1" type="radio">
<input name="slider" class="slide-radio2" id="slider_2" type="radio">
<input name="slider" class="slide-radio3" id="slider_3" type="radio">
<div class="slider-pagination">
<label for="slider_1" class="page1"></label>
<label for="slider_2" class="page2"></label>
<label for="slider_3" class="page3"></label>
</div>
<div class="slider slide1">
<div>
<img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/racing-980x400.jpg">
</div>
</div>
<div class="slider slide2">
<div>
<img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/evoACCURACY_980x400px.jpg">
</div>
</div>
<div class="slider slide3">
<div>
<img src="http://remote.fizzmod.com/ibNZlyN7LX319Mlx/frontend/images/racing-980x400.jpg">
</div>
</div>
</div>
use style :
.css-slider-wrapper {
position: relative;
}
.slide1 {
left: 0;
}
try it i thing it's work other give me Demo line https://jsfiddle.net/

How can I position these thumbnails under the slider?

So, I found this cool css/html slider on a website, so I downloaded the code, and am going to study it. I've started to edit it and style it to my own needs, and I came upon this problem: when I added an image of a bigger size than the originals, the navigation thumbnails got covered. I want them under the slider.
CSS and HTML
* {
margin: 0;
padding: 0;
}
body {
background: #FFF;
}
.slider {
width: 640px;
position: relative;
padding-top: 320px;
margin: 100px auto;
box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.75);
}
.slider>img {
position: absolute;
left: 0;
top: 0;
transition: all 0.5s;
}
.slider input[name='slide_switch'] {
display: none;
}
.slider label {
margin: 18px 0 0 18px;
border: 3px solid #999;
float: left;
cursor: pointer;
transition: all 0.5s;
opacity: 0.6;
}
.slider label img {
display: block;
}
.slider input[name='slide_switch']:checked+label {
border-color: #666;
opacity: 1;
}
.slider input[name='slide_switch'] ~ img {
opacity: 0;
transform: scale(1.1);
}
.slider input[name='slide_switch']:checked+label+img {
opacity: 1;
transform: scale(1);
}
<div class="slider">
<input type="radio" name="slide_switch" id="id2" checked="checked" />
<label for="id2">
<img src="http://www.placehold.it/100" width="100" />
</label>
<img src="http://www.placehold.it/200X800" />
<input type="radio" name="slide_switch" id="id3" />
<label for="id3">
<img src="http://www.placehold.it/100/FF0000" width="100" />
</label>
<img src="http://www.placehold.it/640X320/FF0000" />
<input type="radio" name="slide_switch" id="id4" />
<label for="id4">
<img src="http://www.placehold.it/100/FF9900" width="100" />
</label>
<img src="http://www.placehold.it/640X320/FF9900" />
<input type="radio" name="slide_switch" id="id5" />
<label for="id5">
<img src="http://www.placehold.it/100/FFFF99" width="100" />
</label>
<img src="http://www.placehold.it/640X320/FFFF99" />
</div>
<script src="http://thecodeplayer.com/uploads/js/prefixfree.js" type="text/javascript"></script>
Start by restricting the width and height of the img to its container:
.slider > img {
max-width: 100%;
max-height: 100%;
}
Now, let's centre the image, this will look a lot better for images that don't span the width of the container:
.slider > img gets left: 50% and transform: translateX(-50%) (placed next to the existing scale transform).
Working Example
* {
margin: 0;
padding: 0;
}
body {
background: #FFF;
}
.slider {
width: 640px;
position: relative;
padding-top: 320px;
margin: 100px auto;
box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.75);
}
.slider>img {
position: absolute;
left: 50%;
top: 0;
max-width: 100%;
max-height: 100%;
transition: all 0.5s;
}
.slider input[name='slide_switch'] {
display: none;
}
.slider label {
margin: 18px 0 0 18px;
border: 3px solid #999;
float: left;
cursor: pointer;
transition: all 0.5s;
opacity: 0.6;
}
.slider label img {
display: block;
}
.slider input[name='slide_switch']:checked+label {
border-color: #666;
opacity: 1;
}
.slider input[name='slide_switch'] ~ img {
opacity: 0;
transform: scale(1.1) translateX(-50%);
}
.slider input[name='slide_switch']:checked+label+img {
opacity: 1;
transform: scale(1) translateX(-50%);
}
<div class="slider">
<input type="radio" name="slide_switch" id="id2" checked="checked" />
<label for="id2">
<img src="http://www.placehold.it/100" width="100" />
</label>
<img src="http://www.placehold.it/640X320" />
<input type="radio" name="slide_switch" id="id3" />
<label for="id3">
<img src="http://www.placehold.it/100/FF0000" width="100" />
</label>
<img src="http://www.placehold.it/1000X1000/FF0000" />
<input type="radio" name="slide_switch" id="id4" />
<label for="id4">
<img src="http://www.placehold.it/100/FF9900" width="100" />
</label>
<img src="http://www.placehold.it/640X320/FF9900" />
<input type="radio" name="slide_switch" id="id5" />
<label for="id5">
<img src="http://www.placehold.it/100/FFFF99" width="100" />
</label>
<img src="http://www.placehold.it/640X320/FFFF99" />
</div>
<script src="http://thecodeplayer.com/uploads/js/prefixfree.js" type="text/javascript"></script>
You can give a max-width and a max-height to your images so that they always fit in the container without stretching.
.slider>img {
position: absolute;
left: 0;
top: 0;
transition: all 0.5s;
/* ADD THESE LINES */
max-width: 100%;
max-height: 100%;
}