on change css selector for select element - html

I have created a select box with custom css but the problem is that i want to make the custom arrow to downwards once you select it, so right now if i select any option the arrow will be upward, after selection if i click outside only it comes to default downward position.
Since i am using focus this issue comes, what is the better selector so that user clicks on select box it will be upward and once he selects it comes to normal downwards
see the sample snippet
.select {
width: 40%;
height: 50px;
border: 0;
border-left: 1px solid rgba(112, 112, 112, 0.1);
background: transparent;
border-radius: 0;
appearance: none;
-webkit-appearance: none;
padding-left: 15px;
color: green;
background-color: #32a8a6;
border-radius: 2px;
background-position: calc(100% - 20px) calc(1em + 7px),
calc(100% - 15px) calc(1em + 7px), calc(100% - 2.5em) 0.5em;
background-size: 5px 5px, 5px 5px, 1px 1.5em;
background-repeat: no-repeat;
background-image: linear-gradient(45deg, transparent 50%, gray 50%),
linear-gradient(135deg, gray 50%, transparent 50%);
font-family: ProximaNova, Arial, Helvetica Neue, sans-serif;
}
.select:focus {
background-image: linear-gradient(45deg, grey 50%, transparent 50%),
linear-gradient(135deg, transparent 50%, grey 50%);
background-position: calc(100% - 15px) 23px, calc(100% - 20px) 23px,
calc(100% - 2.5em) 0.5em;
background-size: 5px 5px, 5px 5px, 1px 1.5em;
background-repeat: no-repeat;
outline: 0;
}
.select:-moz-focus {
color: transparent;
text-shadow: 0 0 0 #000;
}
<select class='select'>
<option>one</option>
<option>two</option>
</select>

You can use the :active pseudo class instead.
Since it can be hard to see the arrow direction in the example below when the options are showing, I've changed the background color instead to demonstrate the effect.
.select {
width: 40%;
height: 50px;
border: 0;
border-left: 1px solid rgba(112, 112, 112, 0.1);
background: transparent;
border-radius: 0;
appearance: none;
-webkit-appearance: none;
padding-left: 15px;
color: green;
background-color: #32a8a6;
border-radius: 2px;
background-position: calc(100% - 20px) calc(1em + 7px),
calc(100% - 15px) calc(1em + 7px), calc(100% - 2.5em) 0.5em;
background-size: 5px 5px, 5px 5px, 1px 1.5em;
background-repeat: no-repeat;
background-image: linear-gradient(45deg, transparent 50%, gray 50%),
linear-gradient(135deg, gray 50%, transparent 50%);
font-family: ProximaNova, Arial, Helvetica Neue, sans-serif;
}
.select:active {
background-color: red;
}
<select class='select'>
<option>one</option>
<option>two</option>
</select>

Try replacing .select:focus with .select:focus:active
.select {
width: 40%;
height: 50px;
border: 0;
border-left: 1px solid rgba(112, 112, 112, 0.1);
background: transparent;
border-radius: 0;
appearance: none;
-webkit-appearance: none;
padding-left: 15px;
color: green;
background-color: #32a8a6;
border-radius: 2px;
background-position: calc(100% - 20px) calc(1em + 7px),
calc(100% - 15px) calc(1em + 7px), calc(100% - 2.5em) 0.5em;
background-size: 5px 5px, 5px 5px, 1px 1.5em;
background-repeat: no-repeat;
background-image: linear-gradient(45deg, transparent 50%, gray 50%),
linear-gradient(135deg, gray 50%, transparent 50%);
font-family: ProximaNova, Arial, Helvetica Neue, sans-serif;
}
.select:focus:active {
background-image: linear-gradient(45deg, grey 50%, transparent 50%),
linear-gradient(135deg, transparent 50%, grey 50%);
background-position: calc(100% - 15px) 23px, calc(100% - 20px) 23px,
calc(100% - 2.5em) 0.5em;
background-size: 5px 5px, 5px 5px, 1px 1.5em;
background-repeat: no-repeat;
outline: 0;
}
.select:-moz-focus {
color: transparent;
text-shadow: 0 0 0 #000;
}
<select class='select'>
<option>one</option>
<option>two</option>
</select>

Related

how to add a circle at end of HTML "progress" bar created with <progress> tag

I could able to get progress bar with below code, but couldn't find solution how to add a small circle on the progress bar ?
HTML
<progress max="100" value="75"></progress>
CSS
progress {
width: 90%;
display: block; /* default: inline-block */
padding: 3px;
border: 0 none;
background: rgb(215, 211, 211);
border-radius: 14px;
}
progress::-moz-progress-bar {
border-radius: 12px;
background: linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
}
progress::-webkit-progress-bar {
background: transparent;
}
progress::-webkit-progress-value {
border-radius: 12px;
background: linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
}
Add a second background using a radial-gradient
progress {
width: 90%;
display: block; /* default: inline-block */
margin-bottom:1em;
padding: 3px;
border: 0 none;
background: rgb(215, 211, 211);
border-radius: 14px;
}
progress::-moz-progress-bar {
border-radius: 12px;
background: linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
}
progress::-webkit-progress-bar {
background: transparent;
}
progress::-webkit-progress-value {
border-radius: 12px;
background: radial-gradient(4px at 97%,white,white 4px,transparent),linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%))
;
}
<progress max="100" value="75"></progress>
<progress max="100" value="50"></progress>
<progress max="100" value="25"></progress>
I have no idea how to add a circle at the end of the progress element, but it is possible to do it with the div element
CSS:
.first{
width: 90%;
display: block; /* default: inline-block */
padding: 3px;
border: 0 none;
background: rgb(215, 211, 211);
border-radius: 14px;
}
.second{
background: linear-gradient(to right, hsl(6, 100%, 80%), hsl(335, 100%, 65%));
border-radius: 14px;
height: 10px;
width: 75%;
}
.third{
width: 10px;
background: linear-gradient(to right, hsl(0, 0%, 100%), hsl(0, 0%, 99%));
border-radius: 60px;
height: 8px;
width: 8px;
margin: 1px;
margin-right: 1px !important;
float: right;
margin-right: 0px;
color: white;
}
HTML:
<div class="first">
<div class="second">
<div class="third">.</div>
</div>
</div>

Unexpected image keep appearing

I want to combine input and select as well as some arrow beside to make it look pretty. The problem is whenever I hover my mouse over, another copy of my arrow appear inside the text field which confuse me a lot. Even when I disable hoover, it still appear.
My CSS and HTML:
input {
/* styling */
background-color: white;
border: thin solid blue;
border-radius: 4px;
display: inline-block;
font: inherit;
line-height: 1.5em;
padding: 0.5em 3.5em 0.5em 1em;
/* reset */
margin: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
}
/* arrows */
input.classic {
background-image: linear-gradient(45deg, transparent 50%, blue 50%), linear-gradient(135deg, blue 50%, transparent 50%), linear-gradient(to right, skyblue, skyblue);
background-position: calc(100% - 20px) calc(1em + 2px), calc(100% - 15px) calc(1em + 2px), 100% 0;
background-size: 5px 5px, 5px 5px, 2.5em 2.5em;
background-repeat: no-repeat;
}
input.classic:hover {
background-image: linear-gradient(45deg, white 50%, transparent 50%), linear-gradient(135deg, transparent 50%, white 50%), linear-gradient(to right, gray, gray);
background-position: calc(100% - 15px) 1em, calc(100% - 20px) 1em, 100% 0;
background-size: 5px 5px, 5px 5px, 2.5em 2.5em;
background-repeat: no-repeat;
border-color: grey;
outline: 0;
}
input:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 #000;
}
<input class="classic" type="text" name="city" list="cityname" />
<datalist id="cityname">
<option value="Boston">
<option value="Cambridge">
</datalist> input {
You can remove the default arrow with.
input::-webkit-calendar-picker-indicator {
display: none;
}
Working example.
input {
/* styling */
background-color: white;
border: thin solid blue;
border-radius: 4px;
display: inline-block;
font: inherit;
line-height: 1.5em;
padding: 0.5em 3.5em 0.5em 1em;
/* reset */
margin: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
}
/* arrows */
input.classic {
background-image: linear-gradient(45deg, transparent 50%, blue 50%),
linear-gradient(135deg, blue 50%, transparent 50%),
linear-gradient(to right, skyblue, skyblue);
background-position: calc(100% - 20px) calc(1em + 2px),
calc(100% - 15px) calc(1em + 2px), 100% 0;
background-size: 5px 5px, 5px 5px, 2.5em 2.5em;
background-repeat: no-repeat;
}
input.classic:hover {
background-image: linear-gradient(45deg, white 50%, transparent 50%),
linear-gradient(135deg, transparent 50%, white 50%),
linear-gradient(to right, gray, gray);
background-position: calc(100% - 15px) 1em, calc(100% - 20px) 1em,
100% 0;
background-size: 5px 5px, 5px 5px, 2.5em 2.5em;
background-repeat: no-repeat;
border-color: grey;
outline: 0;
}
input:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 #000;
}
input::-webkit-calendar-picker-indicator {
display: none;
}
<input class="classic" type="text" name="city" list="cityname" />
<datalist id="cityname">
<option value="Boston"></option>
<option value="Cambridge"></option>
</datalist>
Just add this script into your CSS
input::-webkit-calendar-picker-indicator {
display: none;
}

How can i do clickable custom dropdown arrow in css?

I set the custom dropdown arrow using css but it is not clickable right know. So how can i fix that?
.container select{
border-radius: 20px;
padding: 5px 38px 7px 23px;
border: 2px solid orange;
appearance: none;
position: relative;
}
.container i.fa-angle-down{
position: absolute;
right: 66.8%;
top: 92.8%;
border-radius: 20px;
color: white;
background-color: orange;
padding: 8px;
padding-left: 10px;
font-size: 20px;
}
<div class="container">
<h6>Current open positions</h6>
<div class="form-group">
<label class="search">Search by Location</label>
<select>
<option>Canada</option>
<option>Dakor</option>
</select><i class="fas fa-angle-down"></i>
</div>
</div>
There are neater ways of doing what you're trying to achieve. Look up Select2.
In saying this though, the reason your dropdown isn't clickable is because it is overlapping the actual dropdown - to circumvent this, add this property;
pointer-events: none; to your .container i.fa-angle-down class.
ie;
.container i.fa-angle-down{
position: absolute;
right: 66.8%;
top: 92.8%;
border-radius: 20px;
color: white;
background-color: orange;
padding: 8px;
padding-left: 10px;
font-size: 20px;
pointer-events: none; //enables click-through
}
This will enable a "click-through" to the object/element behind it.
Another alternative is this solution here that I found for you, a sample can be found here.
It won't work since you are inserting the font outside of the select which excludes it from the select option. you can use select pseudo-element to achieve the same thing. You can find more about it here on font awesome documentation. does it answer your question
Answer :
: How to create a custom dropdown arrow in css?
Here Is The Link, (My CodePen) : Click Here
select {
/* styling */
background-color: white;
border: thin solid blue;
border-radius: 4px;
display: inline-block;
font: inherit;
line-height: 1.5em;
padding: 0.5em 3.5em 0.5em 1em;
/* reset */
margin: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-appearance: none;
-moz-appearance: none;
}
/* arrows */
select.classic {
background-image:
linear-gradient(45deg, transparent 50%, blue 50%),
linear-gradient(135deg, blue 50%, transparent 50%),
linear-gradient(to right, skyblue, skyblue);
background-position:
calc(100% - 20px) calc(1em + 2px),
calc(100% - 15px) calc(1em + 2px),
100% 0;
background-size:
5px 5px,
5px 5px,
2.5em 2.5em;
background-repeat: no-repeat;
}
select.classic:focus {
background-image:
linear-gradient(45deg, white 50%, transparent 50%),
linear-gradient(135deg, transparent 50%, white 50%),
linear-gradient(to right, gray, gray);
background-position:
calc(100% - 15px) 1em,
calc(100% - 20px) 1em,
100% 0;
background-size:
5px 5px,
5px 5px,
2.5em 2.5em;
background-repeat: no-repeat;
border-color: grey;
outline: 0;
}
select.round {
background-image:
linear-gradient(45deg, transparent 50%, gray 50%),
linear-gradient(135deg, gray 50%, transparent 50%),
radial-gradient(#ddd 70%, transparent 72%);
background-position:
calc(100% - 20px) calc(1em + 2px),
calc(100% - 15px) calc(1em + 2px),
calc(100% - .5em) .5em;
background-size:
5px 5px,
5px 5px,
1.5em 1.5em;
background-repeat: no-repeat;
}
select.round:focus {
background-image:
linear-gradient(45deg, white 50%, transparent 50%),
linear-gradient(135deg, transparent 50%, white 50%),
radial-gradient(gray 70%, transparent 72%);
background-position:
calc(100% - 15px) 1em,
calc(100% - 20px) 1em,
calc(100% - .5em) .5em;
background-size:
5px 5px,
5px 5px,
1.5em 1.5em;
background-repeat: no-repeat;
border-color: green;
outline: 0;
}
select.minimal {
background-image:
linear-gradient(45deg, transparent 50%, gray 50%),
linear-gradient(135deg, gray 50%, transparent 50%),
linear-gradient(to right, #ccc, #ccc);
background-position:
calc(100% - 20px) calc(1em + 2px),
calc(100% - 15px) calc(1em + 2px),
calc(100% - 2.5em) 0.5em;
background-size:
5px 5px,
5px 5px,
1px 1.5em;
background-repeat: no-repeat;
}
select.minimal:focus {
background-image:
linear-gradient(45deg, green 50%, transparent 50%),
linear-gradient(135deg, transparent 50%, green 50%),
linear-gradient(to right, #ccc, #ccc);
background-position:
calc(100% - 15px) 1em,
calc(100% - 20px) 1em,
calc(100% - 2.5em) 0.5em;
background-size:
5px 5px,
5px 5px,
1px 1.5em;
background-repeat: no-repeat;
border-color: green;
outline: 0;
}
select:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 #000;
}
body {
background-color: rgb(0,159,214);
font: bold 1em/100% "Helvetica Neue", Arial, sans-serif;
padding: 2em 0;
text-align: center;
}
h1 {
color: white;
line-height: 120%;
margin: 0 auto 2rem auto;
max-width: 30rem;
}
<h1>Tutorial How to create a custom dropdown arrow in css.</h1>
<select class="classic">
<s>CSS SELECT arrow (classic)</s>
<option>No external background image</option>
<option>No wrapper</option>
</select>
<br><br>
<select class="round">
<option>CSS SELECT arrow (round)</option>
<option>No external background image</option>
<option>No wrapper</option>
</select>
<br><br>
<select class="minimal">
<option>CSS SELECT arrow (minimal)</option>
<option>No external background image</option>
<option>No wrapper</option>
</select>
Leave A Like, Comment.
Why not make use of SVG instead of an extra icon?
.container select{
border-radius: 20px;
padding: 5px 38px 7px 23px;
border: 2px solid orange;
background-color: Transparent;
background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 420 512'><path d='M143 352.3L7 216.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.2 9.4-24.4 9.4-33.8 0z' style='fill: rgb(255, 193, 42);'></path></svg>") no-repeat right center;
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
}
<div class="container">
<h6>Current open positions</h6>
<div class="form-group">
<label class="search">Search by Location</label>
<select>
<option>Canada</option>
<option>Dakor</option>
</select>
</div>
</div>

Responsive html css Curly Braces .brace.bottom:after not working

I have a some code for Responsive html css Curly Braces i trying to place the bottom position but its not working correctly . position top is working perfect. anyone know how to change that position to bottom.
Thanks
That's my code
.brace{
border: 2px solid #CCC;
height: 25px;
position:relative;
border-bottom: 0;
border-radius: 25px 25px 0 0;
margin-top: 25px;
}
.brace.top:after{
content: '';
position:absolute;
left: 50%;
width: 50px;
height: 55px;
margin-top: -27px;
margin-left: -25px;
background-color: #FFF;
background:
linear-gradient(135deg, transparent 10px, #CCC 0) top left,
linear-gradient(225deg, transparent 10px, #CCC 0) top right,
linear-gradient(315deg, transparent 10px, #CCC 0) bottom right,
linear-gradient(45deg, transparent 10px, #CCC 0) bottom left;
background-size: 50% 50%;
background-repeat: no-repeat;
background-image:
radial-gradient(circle at 0 0, transparent 25px, #CCC 26px, #FFF 28px ),
radial-gradient(circle at 100% 0, transparent 25px, #CCC 26px, #FFF 28px),none,none;
}
.brace.bottom{
border-top: 0;
border-bottom: 2px solid #CCC;
border-radius: 0 0 25px 25px;
margin-top: 0;
}
.brace.bottom:after{
content: '';
position:absolute;
left: 50%;
width: 50px;
height: 55px;
margin-top: 0px;
margin-left: -25px;
background-color: #FFF;
background:
linear-gradient(135deg, transparent 10px, #25aae1 0) top left,
linear-gradient(225deg, transparent 10px, #25aae1 0) top right,
linear-gradient(315deg, transparent 10px, #25aae1 0) bottom right,
linear-gradient(45deg, transparent 10px, #25aae1 0) bottom left;
background-size: 50% 50%;
background-repeat: no-repeat;
background-image:
radial-gradient(circle at 0 0, transparent 25px, #25aae1 26px, #25aae1 28px ),
radial-gradient(circle at 100% 0, transparent 25px, #25aae1 26px, #25aae1 28px),none,none;
}
<div class="wrapper">
<div class="content">
<div class="brace top"></div>
<br>
<div class="brace bottom"></div>
</div>
</div>
Plz follow these steps.. Depends on relative the bottom position will be aligned..
.brace {
position: static;
}
.wrapper {
position: relative;
}
.brace.top::after {
margin-top: 0;
bottom: -28px;
}
.brace.bottom:after {
content: '';
position: absolute;
left: 50%;
width: 50px;
height: 55px;
margin-top: -4px;
margin-left: -25px;
background-color: #FFF;
background: linear-gradient(135deg, transparent 10px, #CCC 0) top left, linear-gradient(225deg, transparent 10px, #CCC 0) top right, linear-gradient(315deg, transparent 10px, #CCC 0) bottom right, linear-gradient(45deg, transparent 10px, #CCC 0) bottom left;
background-size: 50% 50%;
background-repeat: no-repeat;
background-image: radial-gradient(circle at 0 0, transparent 25px, #CCC 26px, #FFF 28px), radial-gradient(circle at 100% 0, transparent 25px, #CCC 26px, #FFF 28px), none, none;
transform: rotate(180deg);
}
<div class="wrapper">
<div class="content">
<div class="brace top"></div>
<br>
<div class="brace bottom"></div>
</div>
</div>

Bevel corners, background not rounded

I have a figure with bevel corners, but the background is not rounded:
How to have it rounded?
.test-block {
height: 480px;
padding: 4px;
color: #ffffff;
background-color: transparent;
background-image:
-webkit-linear-gradient(top, #ffdc00, #ffdc00),
-webkit-linear-gradient(225deg, #ffdc00, #ffdc00),
-webkit-linear-gradient(bottom, #ffdc00, #ffdc00),
-webkit-linear-gradient(left, #ffdc00, #ffdc00),
-webkit-linear-gradient(315deg, transparent 9px, #ffdc00 10px, #ffdc00 12px, red 12px);
background-image:
linear-gradient(180deg, #1698d9, #1698d9),
linear-gradient(225deg, #1698d9, #1698d9),
linear-gradient(0deg, #1698d9, #1698d9),
linear-gradient(90deg, #1698d9, #1698d9),
linear-gradient(135deg, transparent 28px, #1698d9 28px, #1698d9 32px, #ffffff 10px);
background-position: top right, top right, bottom left, bottom left, top left;
background-size: -webkit-calc(100% - 15px) 2px, 2px 100%, 100% 2px, 2px -webkit-calc(100% - 15px), 100% 100%;
background-size: calc(100% - 40px) 4px, 4px 100%, 100% 4px, 4px calc(100% - 40px), 100% 100%;
background-repeat: no-repeat;
border-radius: 10px;
width: 320px;
}
.test-block__div {
background-image: url(http://css-snippets.com/blogfile/wp-content/uploads/2011/03/square.jpg);
background-repeat: no-repeat;
background-position: -24px 208px;
height: 100%;
}
<div class="test-block">
<div class="test-block__div"></div>
</div>
Since you are using multiple background you can add more using radial-gradiant to create the corner (I removed the vendor prefixes to simplify the code)
.test-block {
height: 480px;
padding: 4px;
color: #ffffff;
background-color: transparent;
background-image:
radial-gradient(circle at top left, transparent 40%, #1698d9 0%),
radial-gradient(circle at bottom left, transparent 40%, #1698d9 0%),
radial-gradient(circle at top right, transparent 40%, #1698d9 0%),
linear-gradient(180deg, #1698d9, #1698d9),
linear-gradient(225deg, #1698d9, #1698d9),
linear-gradient(0deg, #1698d9, #1698d9),
linear-gradient(90deg, #1698d9, #1698d9),
linear-gradient(135deg, transparent 28px, #1698d9 28px, #1698d9 32px, transparent 10px);
background-position:
bottom right,
top right,
bottom left,
top right,
top right,
bottom left,
bottom left,
top left;
background-size:
10px 10px, 10px 10px, 10px 10px,
calc(100% - 40px) 4px,
4px 100%,
100% 4px,
4px calc(100% - 40px),
100% 100%;
background-repeat: no-repeat;
border-radius: 10px;
width: 320px;
}
body {
background-image:linear-gradient(30deg, pink, yellow);
}
<div class="test-block">
</div>
By the way you can achieve the same layout using pseudo-element and without multiples background. It can be easier to handle:
.test-block {
height: 440px;
padding: 4px;
margin-top: 60px;
color: #ffffff;
border-right: 4px solid #1698d9;
border-left: 4px solid #1698d9;
border-bottom: 4px solid #1698d9;
border-radius: 0 0 10px 10px;
width: 320px;
position: relative;
}
.test-block:before {
content: "";
position: absolute;
left: -4px;
width: 50%;
height: 40px;
top: -44px;
border-left: 4px solid #1698d9;
border-top: 4px solid #1698d9;
transform: skewX(-40deg);
transform-origin: bottom left;
}
.test-block:after {
content: "";
position: absolute;
right: -4px;
height: 40px;
width: 50%;
top: -44px;
border-right: 4px solid #1698d9;
border-top: 4px solid #1698d9;
border-radius: 0 10px 0 0;
}
body {
background-image: linear-gradient(30deg, pink, yellow);
}
<div class="test-block">
</div>