How to open a search bar to left - html

I've a search box created in CSS. When I click its icon, it displays input bar. It works perfectly. The only problem is when I click it, it opens input bar in right side area of search icon. I wanted to open it to left side of the icon. How I can do that?
Here's the code I am using:
input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%
}
input::-webkit-search-cancel-button,
input::-webkit-search-decoration {
display: none;
}
input[type=search] {
background: var(--search-color);
border: solid 1px var(--bg-color);
width: 55px;
-webkit-border-radius: 10em;
-moz-border-radius: 10em;
border-radius: 10em;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s
}
input[type=search]:focus {
width: 130px;
background-color: #fff;
border-color: #66cc75;
-webkit-box-shadow: 0 0 5px rgba(109, 207, 246, .5);
-moz-box-shadow: 0 0 5px rgba(109, 207, 246, .5);
box-shadow: 0 0 5px rgba(109, 207, 246, .5)
}
#sv2 input[type=search] {
width: 24px;
padding-left: 10px;
color: transparent;
cursor: pointer;
outline: 0
}
#sv2 input[type=search]:hover {
background-color: var(--bg-color)
}
#sv2 input[type=search]:focus {
width: 160px;
padding-left: 32px;
color: var(--font-color);
background-color: var(--bg-color);
cursor: auto
}
#sv2 input:-moz-placeholder {
color: transparent
}
#sv2 input::-webkit-input-placeholder {
color: transparent
}
<form method="get" action="https://www.example.com/" id="sv2">
<input name="s" id="s" size="30" type="search" placeholder="Search example.com">
</form>
Thanks for your help!

To change the size from right to left, you have to move the whole page with direction: rtl; Adjust it.
body {
background: #fff;
color: #666;
font: 90%/180% Arial, Helvetica, sans-serif;
width: 800px;
max-width: 96%;
margin: 0 auto;
direction: rtl;
}
a {
color: #69C;
text-decoration: none;
}
a:hover {
color: #F60;
}
h1 {
font: 1.7em;
line-height: 110%;
color: #000;
}
p {
margin: 0 0 20px;
}
input {
outline: none;
}
input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
}
input::-webkit-search-decoration,
input::-webkit-search-cancel-button {
display: none;
}
input[type=search] {
background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #ccc;
padding: 9px 10px 9px 32px;
width: 55px;
-webkit-border-radius: 10em;
-moz-border-radius: 10em;
border-radius: 10em;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
input[type=search]:focus {
width: 130px;
background-color: #fff;
border-color: #66CC75;
-webkit-box-shadow: 0 0 5px rgba(109, 207, 246, .5);
-moz-box-shadow: 0 0 5px rgba(109, 207, 246, .5);
box-shadow: 0 0 5px rgba(109, 207, 246, .5);
}
input:-moz-placeholder {
color: #999;
}
input::-webkit-input-placeholder {
color: #999;
}
/* Demo 2 */
#demo-2 input[type=search] {
width: 15px;
padding-left: 10px;
color: transparent;
cursor: pointer;
}
#demo-2 input[type=search]:hover {
background-color: #fff;
}
#demo-2 input[type=search]:focus {
width: 130px;
padding-left: 32px;
color: #000;
background-color: #fff;
cursor: auto;
}
#demo-2 input:-moz-placeholder {
color: transparent;
}
#demo-2 input::-webkit-input-placeholder {
color: transparent;
}
<h1>Expandable Search Form</h1>
<p>Pen by Prinzadi</p>
<h3>Demo 1</h3>
<form>
<input type="search" placeholder="Search">
</form>
<h3>Demo 2</h3>
<form id="demo-2">
<input type="search" placeholder="Search">
</form>
Or adjust it by setting the input with the position: absolute; and setting the right:0;.
body {
background: #fff;
color: #666;
font: 90%/180% Arial, Helvetica, sans-serif;
width: 100%;
max-width: 96%;
margin: 0 auto;
}
a {
color: #69C;
text-decoration: none;
}
a:hover {
color: #F60;
}
h1 {
font: 1.7em;
line-height: 110%;
color: #000;
}
p {
margin: 0 0 20px;
}
input {
outline: none;
}
input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
}
input::-webkit-search-decoration,
input::-webkit-search-cancel-button {
display: none;
}
input[type=search] {
background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #ccc;
padding: 9px 10px 9px 32px;
width: 55px;
-webkit-border-radius: 10em;
-moz-border-radius: 10em;
border-radius: 10em;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
input[type=search]:focus {
width: 130px;
background-color: #fff;
border-color: #66CC75;
-webkit-box-shadow: 0 0 5px rgba(109, 207, 246, .5);
-moz-box-shadow: 0 0 5px rgba(109, 207, 246, .5);
box-shadow: 0 0 5px rgba(109, 207, 246, .5);
}
input:-moz-placeholder {
color: #999;
}
input::-webkit-input-placeholder {
color: #999;
}
#myForm {
position: relative;
width: 160px;
}
#myForm input[type=search] {
position: absolute;
right: 0;
}
<h1>Expandable Search Form</h1>
<p>Pen by Prinzadi</p>
<h3>Demo 1</h3>
<form id="myForm">
<input type="search" placeholder="Search">
</form>

Related

How to associate label with checkbox but not using "for=id"

i have this code:
<li><input type="checkbox" id="checkboxThree" value="Alergia3" ><label for="checkboxThree">Alergia 1</label></li>
<li><input type="checkbox" id="checkboxFour" value="Alergia4"><label for="checkboxFour">Alergia 1</label></li>
<li><input type="checkbox" id="checkboxFive" value="Alergia5"><label for="checkboxFive">Alergia 1</label></li>
<li><input type="checkbox" id="checkboxSix" value="Alergia6" ><label for="checkboxSix">Alergia 1</label></li>
But I don't want to use "id" and "for" because I have to do other thing later and I can't use them. I have see this question: Possible to associate label with checkbox without using "for=id"? and I have triet what the first peson says:
<li><label ><input type="checkbox" name="Alergia1">Alergia 1</label></li>
<li><label ><input type="checkbox" name="Alergia2" >Alergia 1</label></li>
But It does not work either.
This is the entire project to see that it does not work:
.font-robo {
font-family: "Roboto", "Arial", "Helvetica Neue", sans-serif;
}
.font-poppins {
font-family: "Poppins", "Arial", "Helvetica Neue", sans-serif;
}
html {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
* {
padding: 0;
margin: 0;
}
*, *:before, *:after {
-webkit-box-sizing: inherit;
-moz-box-sizing: inherit;
box-sizing: inherit;
}
/* ==========================================================================
#GRID
========================================================================== */
/* ==========================================================================
#BOX-SIZING
========================================================================== */
/**
* More sensible default box-sizing:
* css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice
*/
/* ==========================================================================
#RESET
========================================================================== */
/**
* A very simple reset that sits on top of Normalize.css.
*/
body,
h1, h2, h3, h4, h5, h6,
blockquote, p, pre,
dl, dd, ol, ul,
figure,
hr,
fieldset, legend {
margin: 0;
padding: 0;
}
/**
* Remove trailing margins from nested lists.
*/
li > ol,
li > ul {
margin-bottom: 0;
}
/**
* Remove default table spacing.
*/
table {
border-collapse: collapse;
border-spacing: 0;
}
/**
* 1. Reset Chrome and Firefox behaviour which sets a `min-width: min-content;`
* on fieldsets.
*/
fieldset {
min-width: 0;
/* [1] */
border: 0;
}
button {
outline: none;
background: none;
border: none;
}
/* ==========================================================================
#PAGE WRAPPER
========================================================================== */
.page-wrapper {
height:100vh;
}
body {
font-family: "Poppins", "Arial", "Helvetica Neue", sans-serif;
font-weight: 400;
font-size: 14px;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 400;
}
h1 {
font-size: 36px;
}
h2 {
font-size: 30px;
color: #00929a !important;
}
h3 {
font-size: 24px;
}
h4 {
font-size: 18px;
}
h5 {
font-size: 15px;
}
h6 {
font-size: 13px;
}
/* ==========================================================================
#BACKGROUND
========================================================================== */
.bg-blue {
background: #2c6ed5;
}
.bg-red {
background: #fa4251;
}
.bg-gra-01 {
background: -webkit-gradient(linear, left bottom, left top, from(#00929a), to(#034649));
background: -webkit-linear-gradient(bottom, #00929a 0%, #034649 100%);
background: -moz-linear-gradient(bottom, #00929a 0%, #034649 100%);
background: -o-linear-gradient(bottom, #00929a 0%, #034649 100%);
background: linear-gradient(to top, #00929a 0%, #034649 100%);
}
.bg-gra-02 {
background: -webkit-gradient(linear, left bottom, right top, from(#00929a), to(#034649));
background: -webkit-linear-gradient(bottom left, #00929a 0%, #034649 100%);
background: -moz-linear-gradient(bottom left, #00929a 0%, #034649 100%);
background: -o-linear-gradient(bottom left, #00929a 0%, #034649 100%);
background: linear-gradient(to top right, #00929a 0%, #034649 100%);
}
/* ==========================================================================
#CHECKBOX
========================================================================== */
.container {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 13px;
}
ul.ks-cboxtags {
list-style: none;
margin-bottom: 20px;
}
ul.ks-cboxtags li{
display: inline;
}
ul.ks-cboxtags li label{
display: inline-block;
background-color: rgba(255, 255, 255, .9);
border: 2px solid rgba(139, 139, 139, .3);
color: #adadad;
border-radius: 25px;
white-space: nowrap;
margin: 3px 0px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-tap-highlight-color: transparent;
transition: all .2s;
}
ul.ks-cboxtags li label {
padding: 20px 20px;
cursor: pointer;
margin:20px;
}
ul.ks-cboxtags li label::before {
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
font-family: "Font Awesome 5 Free";
font-weight: 900;
font-size: 12px;
padding: 20px;
transition: transform .3s ease-in-out;
}
ul.ks-cboxtags li input[type="checkbox"]:checked + label {
border: 2px solid #00929a;
background-color: #00929a;
color: #fff;
transition: all .2s;
}
ul.ks-cboxtags li input[type="checkbox"] {
display: absolute;
}
ul.ks-cboxtags li input[type="checkbox"] {
position: absolute;
width: 60vh;
opacity: 0;
}
ul.ks-cboxtags li input[type="checkbox"]:focus + label {
border: 2px solid #034649;
}
/* ==========================================================================
#SPACING
========================================================================== */
.p-t-100 {
padding-top: 100px;
}
.p-t-130 {
padding-top: 130px;
}
.p-t-180 {
padding-top: 180px;
}
.p-t-20 {
padding-top: 20px;
}
.p-t-15 {
padding-top: 15px;
}
.p-t-10 {
padding-top: 10px;
}
.p-t-30 {
padding-top: 30px;
}
.p-b-100 {
padding-bottom: 100px;
}
.m-r-45 {
margin-right: 45px;
}
/* ==========================================================================
#WRAPPER
========================================================================== */
.wrapper {
margin: 0 auto;
}
.wrapper--w960 {
max-width: 960px;
}
.wrapper--w780 {
max-width: 780px;
}
.wrapper--w680 {
max-width: 680px;
}
/* ==========================================================================
#BUTTON
========================================================================== */
.btn {
display: inline-block;
line-height: 50px;
padding: 0 50px;
-webkit-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
transition: all 0.4s ease;
cursor: pointer;
font-size: 18px;
color: #fff;
font-family: "Poppins", "Arial", "Helvetica Neue", sans-serif;
}
.btn--radius {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.btn--radius-2 {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.btn--pill {
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
.btn--green {
background: #00929a;
}
.btn--green:hover {
background: #00929a;
}
.btn--blue {
background: #034649;
}
.btn--blue:hover {
background: #034649;
}
/* ==========================================================================
#DATE PICKER
========================================================================== */
td.active {
background-color: #034649;
}
input[type="date" i] {
padding: 14px;
}
.table-condensed td, .table-condensed th {
font-size: 14px;
font-family: "Roboto", "Arial", "Helvetica Neue", sans-serif;
font-weight: 400;
}
.daterangepicker td {
width: 40px;
height: 30px;
}
.daterangepicker {
border: none;
-webkit-box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
display: none;
border: 1px solid #e0e0e0;
margin-top: 5px;
}
.daterangepicker::after, .daterangepicker::before {
display: none;
}
.daterangepicker thead tr th {
padding: 10px 0;
}
.daterangepicker .table-condensed th select {
border: 1px solid #ccc;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
font-size: 14px;
padding: 5px;
outline: none;
}
/* ==========================================================================
#FORM
========================================================================== */
input {
outline: none;
margin: 0;
border: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
width: 100%;
font-size: 14px;
font-family: inherit;
}
.input--style-4 {
line-height: 50px;
background: #fafafa;
-webkit-box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
-moz-box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 0 20px;
font-size: 16px;
color: #666;
-webkit-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.input--style-4::-webkit-input-placeholder {
/* WebKit, Blink, Edge */
color: #666;
}
.input--style-4:-moz-placeholder {
/* Mozilla Firefox 4 to 18 */
color: #666;
opacity: 1;
}
.input--style-4::-moz-placeholder {
/* Mozilla Firefox 19+ */
color: #666;
opacity: 1;
}
.input--style-4:-ms-input-placeholder {
/* Internet Explorer 10-11 */
color: #666;
}
.input--style-4:-ms-input-placeholder {
/* Microsoft Edge */
color: #666;
}
.label {
font-size: 16px;
color: #555;
text-transform: capitalize;
display: block;
margin-bottom: 5px;
}
.radio-container {
display: inline-block;
position: relative;
padding-left: 30px;
cursor: pointer;
font-size: 16px;
color: #666;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.radio-container input {
position: absolute;
opacity: 0;
cursor: pointer;
}
.radio-container input:checked ~ .checkmark {
background-color: #e5e5e5;
}
.radio-container input:checked ~ .checkmark:after {
display: block;
}
.radio-container .checkmark:after {
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 12px;
height: 12px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
background: #00929a;
}
.checkmark {
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
left: 0;
height: 20px;
width: 20px;
background-color: #e5e5e5;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
-webkit-box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
-moz-box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
}
.checkmark:after {
content: "";
position: absolute;
display: none;
}
.input-group {
position: relative;
margin-bottom: 22px;
}
.input-group-icon {
position: relative;
}
.input-icon {
position: absolute;
font-size: 18px;
color: #999;
right: 18px;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
cursor: pointer;
}
/* ==========================================================================
#SELECT2
========================================================================== */
.select--no-search .select2-search {
display: none !important;
}
.rs-select2 .select2-container {
width: 100% !important;
outline: none;
background: #fafafa;
-webkit-box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
-moz-box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
box-shadow: inset 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.rs-select2 .select2-container .select2-selection--single {
outline: none;
border: none;
height: 50px;
background: transparent;
}
.rs-select2 .select2-container .select2-selection--single .select2-selection__rendered {
line-height: 50px;
padding-left: 0;
color: #555;
font-size: 16px;
font-family: inherit;
padding-left: 22px;
padding-right: 50px;
}
.rs-select2 .select2-container .select2-selection--single .select2-selection__arrow {
height: 50px;
right: 20px;
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
-moz-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-moz-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.rs-select2 .select2-container .select2-selection--single .select2-selection__arrow b {
display: none;
}
.rs-select2 .select2-container .select2-selection--single .select2-selection__arrow:after {
font-family: "Material-Design-Iconic-Font";
content: '\f2f9';
font-size: 24px;
color: #999;
-webkit-transition: all 0.4s ease;
-o-transition: all 0.4s ease;
-moz-transition: all 0.4s ease;
transition: all 0.4s ease;
}
.rs-select2 .select2-container.select2-container--open .select2-selection--single .select2-selection__arrow::after {
-webkit-transform: rotate(-180deg);
-moz-transform: rotate(-180deg);
-ms-transform: rotate(-180deg);
-o-transform: rotate(-180deg);
transform: rotate(-180deg);
}
.select2-container--open .select2-dropdown--below {
border: none;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
border: 1px solid #e0e0e0;
margin-top: 5px;
overflow: hidden;
}
.select2-container--default .select2-results__option {
padding-left: 22px;
}
/* ==========================================================================
#TITLE
========================================================================== */
.title {
font-size: 30px;
font-weight: 400;
margin-bottom: 20px;
}
/*========================================================================== */
.frase {
font-size: 18px;
color: #525252;
font-weight: 400;
margin-bottom: 40px;
}
/* ==========================================================================
#CARD
========================================================================== */
.card {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background: #fff;
}
.card-4 {
background: #fff;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.15);
}
.card-4 .card-body {
padding: 17px 50px;
padding-bottom: 55px;
padding-top: 20px;
}
#media (max-width: 767px) {
.card-4 .card-body {
padding: 50px 40px;
}
}
<!DOCTYPE html>
<html lang="es">
<head>
<!-- Required meta tags-->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Title Page-->
<title>Alergias</title>
<!-- Icons font CSS-->
<link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css">
<!-- Font special for pages-->
<link href="https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<!-- Vendor CSS-->
<!-- Main CSS-->
<link href="css/alergias.css" rel="stylesheet" media="all">
</head>
<body>
<div class="page-wrapper bg-gra-02 p-t-130 p-b-100 font-poppins">
<div class="wrapper wrapper--w680">
<div class="card card-4">
<div class="card-body">
<h2 class="title">Alergias</h2>
<h5 class="frase">Por favor, elige todas las alergias que tengas, para poder hacer los menus adaptados a ti:</h5>
<form method="POST">
<!---------------------------------------------------------------------->
<div class="container">
<ul class="ks-cboxtags">
<li><label ><input type="checkbox" name="Alergia1">Alergia 1</label></li>
<li><label ><input type="checkbox" name="Alergia2" >Alergia 1</label></li>
<li><input type="checkbox" id="checkboxThree" value="Alergia3" ><label for="checkboxThree">Alergia 1</label></li>
<li><input type="checkbox" id="checkboxFour" value="Alergia4"><label for="checkboxFour">Alergia 1</label></li>
<li><input type="checkbox" id="checkboxFive" value="Alergia5"><label for="checkboxFive">Alergia 1</label></li>
<li><input type="checkbox" id="checkboxSix" value="Alergia6" ><label for="checkboxSix">Alergia 1</label></li>
<li><input type="checkbox" id="checkboxSeven" value="Alergia7"><label for="checkboxSeven">Alergia 1</label></li>
<li><input type="checkbox" id="checkboxEight" value="Alergia8"><label for="checkboxEight">Alergia 1</label></li>
</ul>
</div>
<!---------------------------------------------------------------------->
<div class="p-t-15">
<button class="btn btn--radius-2 btn--blue" type="submit">Registrarse</button>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
So the first two checkboxes doesn't work.
Is there other way to do that? Thank you!
It doesn't seem to work for the first two "checkboxes" because putting the checkboxes in the label elements makes this CSS rule stop working:
ul.ks-cboxtags li input[type="checkbox"]:checked + label
That rule only applies to a checkbox followed by a label, not a label with a checkbox inside it.
If you're going to use the pattern with the checkbox inside the label, you're going to have to find a different way to do the styling. CSS isn't my strong suit, but as I understand it it's hard to style an element based on something inside that element. (There was once, briefly, a :contains pseudo-class, but it was never broadly supported because IIRC there were issues with performance.) This question's answers describe ways to do it, but unfortunately I think you're stuck with JavaScript if you do the containment.

Global Styles Not getting Reflected for Components Angular

I have a button that is common for every component , so instead of styling the components individually i decided to put these button styling in style.css .
But it dosent work all other properties like background and p tag works but not for this button is it beacause of the webkit i am using for this button.
I works when i put it in individual components.
CSS
input {
outline: none;
float: right;
}
input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
}
input::-webkit-search-decoration,
input::-webkit-search-cancel-button {
display: none;
}
input[type=search] {
background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #ccc;
padding: 9px 10px 9px 32px;
width: 55px;
height:15px;
-webkit-border-radius: 10em;
-moz-border-radius: 10em;
border-radius: 10em;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
input[type=search]:focus {
width: 130px;
background-color: #fff;
border-color: #66CC75;
-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
box-shadow: 0 0 5px rgba(109,207,246,.5);
}
input:-moz-placeholder {
color: #999;
}
input::-webkit-input-placeholder {
color: #999;
}
input {
outline: none;
float: right;
}
input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
}
input::-webkit-search-decoration,
input::-webkit-search-cancel-button {
display: none;
}
input[type=search] {
background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #ccc;
padding: 9px 10px 9px 32px;
width: 55px;
height:15px;
-webkit-border-radius: 10em;
-moz-border-radius: 10em;
border-radius: 10em;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
input[type=search]:focus {
width: 130px;
background-color: #fff;
border-color: #66CC75;
-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
box-shadow: 0 0 5px rgba(109,207,246,.5);
}
input:-moz-placeholder {
color: #999;
}
input::-webkit-input-placeholder {
color: #999;
}
TEMPLATE
<div class="col l3 offset-l9">
<input type="search" placeholder="Search" #input>
</div>
This is how it should look
This is how it looking now
I tried using view Encapsulation but i dnt think that makes any diffrence as that is for parent child styling and these are indivdual components
Please help-
to use global styles and disable view css encapsulation
in involved components, add :
#Component({
..
encapsulation: ViewEncapsulation.None,
..
}
Well its working when i tried it
input {
outline: none;
float: right;
}
input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
}
input::-webkit-search-decoration,
input::-webkit-search-cancel-button {
display: none;
}
input[type=search] {
background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #ccc;
padding: 9px 10px 9px 32px;
width: 55px;
height:15px;
-webkit-border-radius: 10em;
-moz-border-radius: 10em;
border-radius: 10em;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
input[type=search]:focus {
width: 130px;
background-color: #fff;
border-color: #66CC75;
-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
box-shadow: 0 0 5px rgba(109,207,246,.5);
}
input:-moz-placeholder {
color: #999;
}
input::-webkit-input-placeholder {
color: #999;
}
input {
outline: none;
float: right;
}
input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
}
input::-webkit-search-decoration,
input::-webkit-search-cancel-button {
display: none;
}
input[type=search] {
background: #ededed url(https://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #ccc;
padding: 9px 10px 9px 32px;
width: 55px;
height:15px;
-webkit-border-radius: 10em;
-moz-border-radius: 10em;
border-radius: 10em;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
input[type=search]:focus {
width: 130px;
background-color: #fff;
border-color: #66CC75;
-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
box-shadow: 0 0 5px rgba(109,207,246,.5);
}
input:-moz-placeholder {
color: #999;
}
input::-webkit-input-placeholder {
color: #999;
}
<div class="col l3 offset-l9">
<input type="search" placeholder="Search" #input>
</div>
[https://jsfiddle.net/xr9fvLgd/]
You can apply the Global Style in the '.angular-cli.json' file and applicable to whole project.
Open your code folder in Visual Studio Code and look for the '.angular-cli.json' file, under the 'apps' array object object, add styles array object.
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
],

Vertical centering with flexbox [duplicate]

This question already has an answer here:
Vertically align a flexbox
(1 answer)
Closed 5 years ago.
I'm currently having issues vertically centering the wrapper. I attempted to create a div that displays flex and aligns items center as suggested by another post and it didn't work. Any ideas why and how to resolve it?
body {
font-family: Arial, sans-serif;
background: #ddd;
}
h1 {
text-align: center;
font-family: "Trebuchet MS", Tahoma, Arial, sans-serif;
color: #333;
text-shadow: 0 1px 0 #fff;
margin: 50px 0;
}
#center {
display: flex;
align-items: center;
}
#wrapper {
width: 100px;
margin: 0 auto;
background: #fff;
padding: 20px;
border: 10px solid #aaa;
border-radius: 15px;
background-clip: padding-box;
text-align: center;
}
.button {
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
padding: 5px 10px;
border: 1px solid #aaa;
background-color: #eee;
background-image: linear-gradient(top, #fff, #f0f0f0);
border-radius: 2px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
color: #666;
text-decoration: none;
text-shadow: 0 1px 0 #fff;
cursor: pointer;
transition: all 0.2s ease-out;
}
.button:hover {
border-color: #999;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.button:active {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
transition: opacity 200ms;
visibility: hidden;
opacity: 0;
}
.overlay.light {
background: rgba(255, 255, 255, 0.5);
}
.overlay .cancel {
position: absolute;
width: 100%;
height: 100%;
cursor: default;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 75px auto;
padding: 20px;
background: #fff;
border: 1px solid #666;
width: 300px;
box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
position: relative;
}
.light .popup {
border-color: #aaa;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.popup h2 {
margin-top: 0;
color: #666;
font-family: "Trebuchet MS", Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
width: 20px;
height: 20px;
top: 20px;
right: 20px;
opacity: 0.8;
transition: all 200ms;
font-size: 24px;
font-weight: bold;
text-decoration: none;
color: #666;
}
.popup .close:hover {
opacity: 1;
}
.popup .content {
max-height: 400px;
overflow: auto;
}
.popup p {
margin: 0 0 1em;
}
.popup p:last-child {
margin: 0;
}
iframe {
border: none;
}
<div id="center">
<div id="wrapper">
<p><a class="button" href="#popup1">Click Me</a></p>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Drop Day</h2>
<a class="close" href="#">×</a>
<div class="content">
<p>Hello</p>
</div>
</div>
</div>
</div>
Your main wrapper (div#center) must have its height defined:
body {
font-family: Arial, sans-serif;
background: #ddd;
}
h1 {
text-align: center;
font-family: "Trebuchet MS", Tahoma, Arial, sans-serif;
color: #333;
text-shadow: 0 1px 0 #fff;
margin: 50px 0;
}
#center {
display: flex;
align-items: center;
/* or any other height you want */
height: 100vh;
}
#wrapper {
width: 100px;
margin: 0 auto;
background: #fff;
padding: 20px;
border: 10px solid #aaa;
border-radius: 15px;
background-clip: padding-box;
text-align: center;
}
.button {
font-family: Helvetica, Arial, sans-serif;
font-size: 13px;
padding: 5px 10px;
border: 1px solid #aaa;
background-color: #eee;
background-image: linear-gradient(top, #fff, #f0f0f0);
border-radius: 2px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
color: #666;
text-decoration: none;
text-shadow: 0 1px 0 #fff;
cursor: pointer;
transition: all 0.2s ease-out;
}
.button:hover {
border-color: #999;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.button:active {
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
transition: opacity 200ms;
visibility: hidden;
opacity: 0;
}
.overlay.light {
background: rgba(255, 255, 255, 0.5);
}
.overlay .cancel {
position: absolute;
width: 100%;
height: 100%;
cursor: default;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 75px auto;
padding: 20px;
background: #fff;
border: 1px solid #666;
width: 300px;
box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
position: relative;
}
.light .popup {
border-color: #aaa;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.popup h2 {
margin-top: 0;
color: #666;
font-family: "Trebuchet MS", Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
width: 20px;
height: 20px;
top: 20px;
right: 20px;
opacity: 0.8;
transition: all 200ms;
font-size: 24px;
font-weight: bold;
text-decoration: none;
color: #666;
}
.popup .close:hover {
opacity: 1;
}
.popup .content {
max-height: 400px;
overflow: auto;
}
.popup p {
margin: 0 0 1em;
}
.popup p:last-child {
margin: 0;
}
iframe {
border: none;
}
<html>
<head>
<meta charset="UTF-8">
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport'>
</head>
<body>
<div id="center">
<div id="wrapper">
<p><a class="button" href="#popup1">Click Me</a></p>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Drop Day</h2>
<a class="close" href="#">×</a>
<div class="content">
<p>Hello</p>
</div>
</div>
</div>
</div>
</body>
</html>

CSS: Styling range input?

I'm trying to style a range input to look like THIS
I have no idea how to style a range input to use own image as the thumb and make the line under the thumb thicker and bigger.
I did put a very basic example in this FIDDLE
Is it even possible to use own image for the range thumb and how would i go about making the line thicker and longer etc?
This is my CSS:
input[type=range] {
-webkit-appearance: none;
background-color: blue;
width: 200px;
height:20px;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
background-color: #666;
opacity: 0.5;
width: 10px;
height: 26px;
background-image:url('THUMB-ICON.png');
}
Any advise would be appreciated.
Getting somewhere I think: https://jsfiddle.net/BNm8j/5586/
Edit:
I made some changes to this but I don't know why the top of the thumb is missing?
https://jsfiddle.net/BNm8j/5588/
any ideas anyone?
here is the original CSS of the example link:
<div id="DIV_1">
<div id="DIV_2">
</div><a id="A_3"></a>
</div>
hope this helps you.
enter code here
#DIV_1 {
box-sizing: border-box;
color: rgb(92, 92, 92);
float: left;
height: 11px;
overflow-wrap: break-word;
position: relative;
touch-action: none;
width: 705px;
word-wrap: break-word;
column-rule-color: rgb(92, 92, 92);
perspective-origin: 352.5px 5.5px;
transform-origin: 352.5px 5.5px;
background: rgb(222, 222, 222) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(92, 92, 92);
border-radius: 3px 3px 3px 3px;
font: normal normal normal normal 16px / normal Omnes, sans-serif;
margin: 11px 30px 0px;
outline: rgb(92, 92, 92) none 0px;
}/*#DIV_1*/
#DIV_2 {
box-sizing: border-box;
color: rgb(92, 92, 92);
height: 11px;
overflow-wrap: break-word;
position: absolute;
top: 0px;
width: 122px;
word-wrap: break-word;
column-rule-color: rgb(92, 92, 92);
perspective-origin: 61px 5.5px;
transform-origin: 61px 5.5px;
background: rgb(0, 143, 213) none repeat scroll 0% 0% / auto padding-box border-box;
border: 0px none rgb(92, 92, 92);
border-radius: 3px 3px 3px 3px;
font: normal normal normal normal 16px / normal Omnes, sans-serif;
outline: rgb(92, 92, 92) none 0px;
}/*#DIV_2*/
#A_3 {
background-position: -65px 0px;
box-sizing: border-box;
color: rgb(247, 144, 47);
cursor: default;
display: block;
height: 59px;
left: 155px;
overflow-wrap: break-word;
position: absolute;
text-decoration: none;
top: -22px;
touch-action: none;
width: 58px;
word-wrap: break-word;
z-index: 100;
column-rule-color: rgb(247, 144, 47);
perspective-origin: 29px 29.5px;
transform-origin: 29px 29.5px;
background: rgba(0, 0, 0, 0) url("https://www.wonga.com/sites/all/themes/pizaz/images/mint/toolkit.png?v=2.2") no-repeat scroll -65px 0px / auto padding-box border-box;
border: 0px none rgb(247, 144, 47);
font: normal normal normal normal 16px / normal Omnes, sans-serif;
margin: 0px 0px 0px -62px;
outline: rgb(247, 144, 47) none 0px;
}/*#A_3*/
Here is a (hopefully) very ease to use tool to customize the style of <input> range:
https://toughengineer.github.io/demo/slider-styler
Here is an example:
for (let e of document.querySelectorAll('input[type="range"].slider-progress')) {
e.style.setProperty('--value', e.value);
e.style.setProperty('--min', e.min == '' ? '0' : e.min);
e.style.setProperty('--max', e.max == '' ? '100' : e.max);
e.addEventListener('input', () => e.style.setProperty('--value', e.value));
}
/*generated with Input range slider CSS style generator (version 20201223)
https://toughengineer.github.io/demo/slider-styler*/
input[type=range].styled-slider {
height: 2.2em;
-webkit-appearance: none;
}
/*progress support*/
input[type=range].styled-slider.slider-progress {
--range: calc(var(--max) - var(--min));
--ratio: calc((var(--value) - var(--min)) / var(--range));
--sx: calc(0.5 * 2em + var(--ratio) * (100% - 2em));
}
input[type=range].styled-slider:focus {
outline: none;
}
/*webkit*/
input[type=range].styled-slider::-webkit-slider-thumb {
width: 2em;
height: 2em;
border-radius: 1em;
background: #007cf8;
border: none;
box-shadow: 0 0 2px black;
margin-top: calc(max((1em - 1px - 1px) * 0.5,0px) - 2em * 0.5);
-webkit-appearance: none;
}
input[type=range].styled-slider::-webkit-slider-runnable-track {
height: 1em;
border-radius: 0.5em;
background: #efefef;
border: 1px solid #b2b2b2;
box-shadow: none;
}
input[type=range].styled-slider::-webkit-slider-thumb:hover {
background: #0061c3;
}
input[type=range].styled-slider:hover::-webkit-slider-runnable-track {
background: #e5e5e5;
border-color: #9a9a9a;
}
input[type=range].styled-slider::-webkit-slider-thumb:active {
background: #2f98f9;
}
input[type=range].styled-slider:active::-webkit-slider-runnable-track {
background: #f5f5f5;
border-color: #c1c1c1;
}
input[type=range].styled-slider.slider-progress::-webkit-slider-runnable-track {
background: linear-gradient(#007cf8,#007cf8) 0/var(--sx) 100% no-repeat, #efefef;
}
input[type=range].styled-slider.slider-progress:hover::-webkit-slider-runnable-track {
background: linear-gradient(#0061c3,#0061c3) 0/var(--sx) 100% no-repeat, #e5e5e5;
}
input[type=range].styled-slider.slider-progress:active::-webkit-slider-runnable-track {
background: linear-gradient(#2f98f9,#2f98f9) 0/var(--sx) 100% no-repeat, #f5f5f5;
}
/*mozilla*/
input[type=range].styled-slider::-moz-range-thumb {
width: 2em;
height: 2em;
border-radius: 1em;
background: #007cf8;
border: none;
box-shadow: 0 0 2px black;
}
input[type=range].styled-slider::-moz-range-track {
height: max(calc(1em - 1px - 1px),0px);
border-radius: 0.5em;
background: #efefef;
border: 1px solid #b2b2b2;
box-shadow: none;
}
input[type=range].styled-slider::-moz-range-thumb:hover {
background: #0061c3;
}
input[type=range].styled-slider:hover::-moz-range-track {
background: #e5e5e5;
border-color: #9a9a9a;
}
input[type=range].styled-slider::-moz-range-thumb:active {
background: #2f98f9;
}
input[type=range].styled-slider:active::-moz-range-track {
background: #f5f5f5;
border-color: #c1c1c1;
}
input[type=range].styled-slider.slider-progress::-moz-range-track {
background: linear-gradient(#007cf8,#007cf8) 0/var(--sx) 100% no-repeat, #efefef;
}
input[type=range].styled-slider.slider-progress:hover::-moz-range-track {
background: linear-gradient(#0061c3,#0061c3) 0/var(--sx) 100% no-repeat, #e5e5e5;
}
input[type=range].styled-slider.slider-progress:active::-moz-range-track {
background: linear-gradient(#2f98f9,#2f98f9) 0/var(--sx) 100% no-repeat, #f5f5f5;
}
/*ms*/
input[type=range].styled-slider::-ms-fill-upper {
background: transparent;
border-color: transparent;
}
input[type=range].styled-slider::-ms-fill-lower {
background: transparent;
border-color: transparent;
}
input[type=range].styled-slider::-ms-thumb {
width: 2em;
height: 2em;
border-radius: 1em;
background: #007cf8;
border: none;
box-shadow: 0 0 2px black;
margin-top: 0;
box-sizing: border-box;
}
input[type=range].styled-slider::-ms-track {
height: 1em;
border-radius: 0.5em;
background: #efefef;
border: 1px solid #b2b2b2;
box-shadow: none;
box-sizing: border-box;
}
input[type=range].styled-slider::-ms-thumb:hover {
background: #0061c3;
}
input[type=range].styled-slider:hover::-ms-track {
background: #e5e5e5;
border-color: #9a9a9a;
}
input[type=range].styled-slider::-ms-thumb:active {
background: #2f98f9;
}
input[type=range].styled-slider:active::-ms-track {
background: #f5f5f5;
border-color: #c1c1c1;
}
input[type=range].styled-slider.slider-progress::-ms-fill-lower {
height: max(calc(1em - 1px - 1px),0px);
border-radius: 0.5em 0 0 0.5em;
margin: -1px 0 -1px -1px;
background: #007cf8;
border: 1px solid #b2b2b2;
border-right-width: 0;
}
input[type=range].styled-slider.slider-progress:hover::-ms-fill-lower {
background: #0061c3;
border-color: #9a9a9a;
}
input[type=range].styled-slider.slider-progress:active::-ms-fill-lower {
background: #2f98f9;
border-color: #c1c1c1;
}
ordinary slider:<br />
<input type="range" class="styled-slider" style="width: 20em;" /><br />
slider with progress styling (made it slightly longer):<br />
<input type="range" class="styled-slider slider-progress" style="width: 30em;" />

How to change the position of image in search box in css?

I have been created simple search form, using by google.
Here is my jsfiddle link: http://jsfiddle.net/njs6d489/
In that, search icon right side right?
But i need icon looking left side and placeholder also need to place left side.
I explained in this image http://s22.postimg.org/ype712rcx/Untitled_1.png
May i know, how can i do this. Is there possible to do this?
Thanks in advance.
body {
background: #fff;
color: #666;
font: 90%/180% Arial, Helvetica, sans-serif;
width: 800px;
max-width: 96%;
margin: 0 auto;
}
a {
color: #69C;
text-decoration: none;
}
a:hover {
color: #F60;
}
input {
outline: none;
}
input[type=search] {
-webkit-appearance: textfield;
-webkit-box-sizing: content-box;
font-family: inherit;
font-size: 100%;
}
input::-webkit-search-decoration,
input::-webkit-search-cancel-button {
display: none;
}
input[type=search] {
background: #ededed url(http://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center;
border: solid 1px #ccc;
padding: 9px 10px 9px 32px;
width: 55px;
-webkit-border-radius: 10em;
-moz-border-radius: 10em;
border-radius: 10em;
-webkit-transition: all .5s;
-moz-transition: all .5s;
transition: all .5s;
}
input[type=search]:focus {
width: 130px;
background-color: #fff;
border-color: #66CC75;
-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
box-shadow: 0 0 5px rgba(109,207,246,.5);
}
input:-moz-placeholder {
color: #999;
}
input::-webkit-input-placeholder {
color: #999;
}
/* Demo 2 */
#demo-2 input[type=search] {
width: 15px;
padding-left: 10px;
color: transparent;
cursor: pointer;
}
#demo-2 input[type=search]:hover {
background-color: #fff;
}
#demo-2 input[type=search]:focus {
width: 130px;
padding-left: 32px;
color: #000;
background-color: #fff;
cursor: auto;
}
#demo-2 input:-moz-placeholder {
color: transparent;
}
#demo-2 input::-webkit-input-placeholder {
color: transparent;
}
Are you expecting like this: Demo
Updated Demo
I changed the search icon's background position at Normal state as 50% and on focus as 90%.
Here I included only the css which I changed.
CSS:
input[type=search] {
background: #ededed url(http://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 50% center;
float:right;
}
input[type=search]:focus {
background: #ededed url(http://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 90% center;
}