I'm trying to center the text inside an HTML select form with CSS, it works on every browser but Safari, I tried with text-align: -webkit-center; but it doesn't work.
select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
label.cw-select {
display: inline-block;
position: relative;
}
.cw-select select {
background: #4d4d4d;
border-radius: 0.3rem;
border: 1px solid #212121;
color: white;
display: inline-block;
height: 30px;
line-height: 1.2;
margin: 0;
min-width: 48px;
outline: none;
padding: 4px 20px 3px 0px;
text-align: center;
text-align: -webkit-center;
text-align: -moz-center;
}
.cw-select:after {
background: #1d1d1d;
border-top-right-radius: 0.3rem;
border-bottom-right-radius: 0.3rem;
bottom: 0;
color: white;
content: "▼";
font-size: 60%;
line-height: 30px;
padding: 0 6px;
pointer-events: none;
position: absolute;
right: 0;
top: 0;
}
<label class="cw-select">
<select name="numberOfPlayers" form="numberOfPlayers">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</label>
Safari
Others
I think the left padding is set to 0. Can you please check this code.
.cw-select select {
background: #4d4d4d;
border-radius: 0.3rem;
border: 1px solid #212121;
color: white;
display: inline-block;
height: 30px;
line-height: 1.2;
margin: 0;
min-width: 48px;
outline: none;
padding: 4px 20px 3px 10px; // instead of 4px 20px 3px 0;
text-align: center;
text-align: -webkit-center;
text-align: -moz-center;
}
Related
We are using AutoCompleteExtender in our project and when checking in IE we don't see the full list but just first element. However, same site works just fine in Edge/Chrome. I did poking around and found that the list/dropdown is there but its somehow hiding behind and just one item hight of data is visible. here is how it looks.
IE:
Edge/Chrome:
IE when using element highligher :
Server side code
<ajaxTK:AutoCompleteExtender ID="AutoCompleteExtenderGoToOrder"
TargetControlID="txtGlobalOrderKeywords"
runat="server"
MinimumPrefixLength="3"
CompletionInterval="500"
CompletionSetCount="20"
ServicePath="~/services/dataAjax.asmx"
ServiceMethod="GetGoToOrderList"
UseContextKey="true"
OnClientItemSelected="extenderOrderSelected"
CompletionListCssClass="autocompletegotoorder_completionListElement"
CompletionListItemCssClass="autocompletegotoorder_listItem"
CompletionListHighlightedItemCssClass="autocompletegotoorder_highlightedListItem"
/>
HTML
<DIV id=Header1_divGotoOrder class=gotoOrder>
<SPAN id=Header1_lblGlobalGoToOrder class=topicHeader style="COLOR: white">Order:</SPAN>
<INPUT id=Header1_hdnGlobalOrderID type=hidden name=Header1$hdnGlobalOrderID>
<INPUT id=Header1_txtGlobalOrderKeywords style="WIDTH: 50%" value=metr name=Header1$txtGlobalOrderKeywords autocomplete="off">
<UL id=Header1_AutoCompleteExtenderGoToOrder_completionListElem class=autocompletegotoorder_completionListElement style="WIDTH: 463px; POSITION: absolute; LEFT: 1405px; Z-INDEX: 1000; DISPLAY: none; TOP: 30px; VISIBILITY: hidden"></UL>
</DIV>
CSS
.autocompletegotoorder_completionListElement
{
padding-bottom: 0px;
padding-top: 0px;
padding-right: 0px;
padding-left: 0px;
position: absolute;
z-index: 9999 !important;
visibility: hidden;
margin-left: -1px !important;
margin-top: 0px !important;
background-color: #F1F0F0;
color: windowtext;
border: buttonshadow;
border-color: Black;
border-width: 1px;
border-style: solid;
cursor: 'default';
overflow: auto;
height: 200px;
text-align: left;
list-style-type: none;
}
/* AutoComplete highlighted item */
.autocompletegotoorder_highlightedListItem
{
list-style-type: none;
font-family: Tahoma;
font-size: 11px;
color: White;
text-decoration: none;
background-color: Navy;
cursor: pointer;
cursor: hand;
padding: 0px 0px 0px 3px;
margin: 0px;
text-align: left;
line-height: 20px !important;
}
/* AutoComplete item */
.autocompletegotoorder_listItem
{
line-height: 20px !important;
background-color: #F1F0F0;
padding: 0px 0px 0px 3px;
margin: 0px;
font-family: Tahoma;
font-size: 11px;
color: black;
cursor: default;
text-decoration: none;
text-align: left;
}
I want to bring the dropdown chevron behind my dropdown so that when I click anywhere on my dropdown, I can see the menu. Right now the chevron-down area is unclickable.
I have looked into other options of using font awesome but have not been able to do so.
<div id="actions-dropdown" class="actions">
<select class="select-option" required [(ngModel)]='optionSelected' (ngModelChange)='onOptionsSelected($event)'>
<option class='option' *ngFor='let option of options' [value]="option">{{option}}</option>
</select>
<i id="arrow" class="fa fa-chevron-down"></i>
</div>
CSS
.select-option {
background: transparent;
background-size: auto auto;
-moz-appearance: none;
padding-top: 0px;
background-size: 20px;
color: #ffffff;
font-size: 30px;
width: 100px;
height: 40px;
border: 1px white solid;
margin: 11px 0px 0px 1071px;
z-index: 5;
}
.fa-chevron-down {
color: red;
z-index: -5;
margin: 0px 0px 0px -5px;
}
Method 2 using Font Awesome
.select-option {
border: 1px solid #ccc;
overflow: hidden;
height: 40px;
width: 240px;
position: relative;
display: block;
background:black;
}
select{
height: 40px;
padding: 5px;
border: 0;
font-size: 16px;
width: 240px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.select-option:after {
content:"\f078";
font-family: FontAwesome;
background: : black;
padding: 12px 8px;
position: absolute; right: 0; top: 0;
background: blue;
z-index: 1;
text-align: center;
width: 10%;
height: 100%;
pointer-events: none;
box-sizing: border-box;
}
change your markup like this. use label instead of i. set pointer-events: none to .fa-chevron-down
<div id="actions-dropdown" class="actions">
<select id="select-el" class="select-option" required [(ngModel)]='optionSelected' (ngModelChange)='onOptionsSelected($event)'>
<option class='option' *ngFor='let option of options' [value]="option">{{option}}</option>
</select>
<label id="arrow" for="select-el" class="fa fa-chevron-down"></label>
</div>
.select-option {
background: transparent;
background-size: auto auto;
-moz-appearance: none;
padding-top: 0px;
background-size: 20px;
color: #ffffff;
font-size: 30px;
width: 100px;
height: 40px;
border: 1px red solid;
margin: 11px 0px 0px 0;
z-index: 5;
}
.actions {
position: relative;
display: inline-block;
}
.fa-chevron-down {
color: red;
z-index: 7;
margin: 0px 0px 0px -5px;
position: absolute;
top:20px;
right:0;
pointer-events:none;
}
.select-option {
border: 1px solid #ccc;
overflow: hidden;
height: 40px;
width: 240px;
position: relative;
display: block;
background:black;
}
select{
height: 40px;
padding: 5px;
border: 0;
font-size: 16px;
width: 240px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.select-option:after {
content:"\f078";
font-family: FontAwesome;
background: : black;
padding: 12px 8px;
position: absolute; right: 0; top: 0;
background: blue;
z-index: 1;
text-align: center;
width: 10%;
height: 100%;
pointer-events: none;
box-sizing: border-box;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" />
<div id="actions-dropdown" class="actions">
<select id="select-el" class="select-option" required>
<option class='option'>option</option>
<option class='option'>option</option>
<option class='option'>option</option>
<option class='option'>option</option>
</select>
<label for="select-el" class="fa fa-chevron-down"></label>
</div>
Case 1) z-index: -5; might be your problem.
.fa-chevron-down {
color: red;
z-index: -5;
margin: 0px 0px 0px -5px;
}
Case 2) .select-option:after not sure if this works because form elements don't have pseudo elements like :before and :after. You might need a different element, like a span to wrap the <select> element and apply :after to span.
for a form I'm creating, I used css to display radio buttons as a toggle-switch.
However its not responsive at all. When viewing on mobile the "scale" 1-5 is broken up in pieces. My goal is to change the with of the scale responsively instead of it breaking up.
Somehow I can't seem to figure it out.
Here's the code: http://jsfiddle.net/7byse1vk/
.toggle__label {
transition: all .25s ease;
display: inline-block;
border-radius: 5px;
background-color: #878787;
cursor: pointer;
padding: 0 30px;
min-width: 100px;
height: 48px;
line-height: 48px;
color: #a7a6ae;
text-align: center;
}
Many thanks in advance!
You can use display: flex; on the parent, remove the min-width from the labels (otherwise that will make them at least 160px wide each, too wide for mobile), and set them to flex-grow: 1 so they fill the parent fluidly.
body {
padding: 20px;
}
.toggle {
margin-bottom: 20px;
}
.row {
display: flex;
}
.toggle__label {
transition: all .25s ease;
border-radius: 5px;
background-color: #878787;
cursor: pointer;
padding: 0 30px;
height: 48px;
line-height: 48px;
color: #a7a6ae;
text-align: center;
flex-grow: 1;
}
.toggle__input:checked + .toggle__label {
background-color: #e5702a;
color: white;
}
.toggle__label--left {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.toggle__label--middle {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
margin-left: -4px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.toggle__label--right {
margin-left: -4px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.toggle__input {
position: absolute;
left: -99999px;
}
label {
padding: 0.4em 2em 0.4em 0;
}
.toggle-btn-grp {
margin: 3px 0;
}
.toggle-btn {
text-align: centre;
margin: 5px 2px;
padding: 0.4em 3em;
color: #000;
background-color: #FFF;
border-radius: 10px;
display: inline-block;
border: solid 1px #CCC;
cursor: pointer;
}
.toggle-btn-grp.joint-toggle .toggle-btn {
margin: 5px 0;
padding: 0.4em 2em;
border-radius: 0;
border-right-color: white;
}
.toggle-btn-grp.joint-toggle .toggle-btn:first-child {
margin-left: 2px;
border-radius: 10px 0px 0px 10px;
}
.toggle-btn-grp.joint-toggle .toggle-btn:last-child {
margin-right: 2px;
border-radius: 0px 10px 10px 0px;
border-right: solid 1px #CCC;
}
.toggle-btn:hover {
border: solid 1px #a0d5dc !important;
background: #f1fdfe;
}
.toggle-btn.success {
background: lightgreen;
border: solid 1px green !important;
}
.visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.visuallyhidden.focusable:active,
.visuallyhidden.focusable:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
}
/* CSS only version */
.toggle-btn-grp.cssonly * {
width: 140px;
height: 30px;
line-height: 30px;
}
.toggle-btn-grp.cssonly div {
display: inline-block;
position: relative;
margin: 5px 2px;
}
.toggle-btn-grp.cssonly div label {
position: absolute;
z-index: 0;
padding: 0;
text-align: center;
}
.toggle-btn-grp.cssonly div input {
position: absolute;
z-index: 1;
cursor: pointer;
opacity: 0;
}
.toggle-btn-grp.cssonly div:hover label {
border: solid 1px #a0d5dc !important;
background: #f1fdfe;
}
.toggle-btn-grp.cssonly div input:checked + label {
background: lightgreen;
border: solid 1px green !important;
}
<div class="row">
<input class="toggle__input" id="option-1" type="radio" name="input4" value="1">
<label class="toggle__label toggle__label--left" for="option-1">1</label>
<input checked="true" class="toggle__input" id="option-2" type="radio" name="input4" value="2">
<label class="toggle__label toggle__label--middle" for="option-2">2</label>
<input class="toggle__input" id="option-3" type="radio" name="input4" value="3">
<label class="toggle__label toggle__label--middle" for="option-3">3</label>
<input class="toggle__input" id="option-4" type="radio" name="input4" value="4">
<label class="toggle__label toggle__label--middle" for="option-4">4</label>
<input class="toggle__input" id="option-5" type="radio" name="input4" value="5">
<label class="toggle__label toggle__label--right" for="option-5">5</label>
</div>
Replace your CSS for the labels below and it'll work. This will scale them down properly. It's because at the moment they've got a minimum set width and are being stretch with the padding because they don't have box-sizing: border-box;.
.toggle__label {
transition: all .25s ease;
display: inline-block;
border-radius: 5px;
background-color: #878787;
cursor: pointer;
padding: 0 30px;
width: 20%;
height: 48px;
line-height: 48px;
color: #a7a6ae;
text-align: center;
float: left;
box-sizing: border-box;
}
I need help for checkbox using CSS only.
First of all it function correctly. However, I want to overlay the checked image on top of the unchecked image when the button is clicked. How to achieve this?
.gchoice_1_1_3 {border: 1px solid red;}
.gchoice_1_1_3 input[type="checkbox"] {display: none; }
.gchoice_1_1_3 input[type="checkbox"] + label:before {
background: url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/christmasLights.png') 0 0px no-repeat;
z-index: 10;
content: "";
display: inline-block;
font-size: 12px;
height: 75px;
width: 75px;
line-height: 16px;
margin: -2px 6px 0 0;
text-align: center;
vertical-align: middle;
positionL relative;
border-radius: 10px;
background-color: #6283B2;
}
.gchoice_1_1_3 input[type="checkbox"]:checked + label:before {
background: url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/checkmark.png') 0 0px no-repeat;
height: 75px;
width: 75px;
border-radius: 10px;
background-color: #37924A;
}
<li class='gchoice_1_1_3'>
<input name='input_1.3' type='checkbox' value='Christmas Lights' id='choice_1_1_3' tabindex='22' />
<label for='choice_1_1_3' id='label_1_1_3'>Christmas Lights</label>
</li>
You can use multiple backgrounds.
But be sure to check browser support and problems with order in which backgrounds are applied.
.gchoice_1_1_3 {border: 1px solid red;}
.gchoice_1_1_3 input[type="checkbox"] {display: none; }
.gchoice_1_1_3 input[type="checkbox"] + label:before {
background: url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/christmasLights.png') 0 0px no-repeat;
z-index: 10;
content: "";
display: inline-block;
font-size: 12px;
height: 75px;
width: 75px;
line-height: 16px;
margin: -2px 6px 0 0;
text-align: center;
vertical-align: middle;
position: relative;
border-radius: 10px;
background-color: #6283B2;
}
.gchoice_1_1_3 input[type="checkbox"]:checked + label:before {
background: url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/checkmark.png'), url('http://www.uswebcompany.com/plugins/gravityforms/wp-content/uploads/2016/01/christmasLights.png') 0 0px no-repeat;
height: 75px;
width: 75px;
border-radius: 10px;
background-color: #37924A;
}
<li class='gchoice_1_1_3'>
<input name='input_1.3' type='checkbox' value='Christmas Lights' id='choice_1_1_3' tabindex='22' />
<label for='choice_1_1_3' id='label_1_1_3'>Christmas Lights</label>
</li>
I'm trying to position a searchbox and submit button so that they are line up. I've used a CSS reset to have all browsers starting from the same level. For whatever reason, I can't get them to line up on the IE, Chrome and Firefox. I can get it working on 1/3 but not 3/3. With the current code, the search button is aligned in FF, 1px lower in IE, and 3-5px lower in Chrome. Any help is much appreciate as I am at my wits end.
Here's the code.
HTML snippet:
<span class="search">
<form id="searchbox" action="/search" method="get">
<input name="query" id="search" type="text" placeholder="I'm looking for..."/>
<input id="submit" class="mglass" type="submit" value=""/>
</form>
</span>
CSS snippet:
* {
vertical-align: baseline;
font-weight: inherit;
font-family: inherit;
font-style: inherit;
font-size: 100%;
border: 0 none;
outline: 0;
padding: 0;
margin: 0;
}
#search{
position: relative;
bottom: 1px;
height: 27px;
width: 200px;
font-size: 14px;
font-family: 'calibri', Tahoma, Geneva, sans-serif;
border: none;
background-color: #eee;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
padding-left: 10px;
}
#searchbox{
position: relative;
right: 27px;
top: 5px;
float: right;
}
input[type="submit"]::-moz-focus-inner {
border: 0;
padding: 0;
}
input[type="text"]::-moz-focus-inner {
border: 0;
padding: 0;
}
.mglass{
background: url(../images/search_glass01.png) no-repeat center;
height: 29px;
width: 33px;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
position: relative;
right: 7px;
bottom: 0px;
}
.mglass:hover{
background: url(../images/search_glass02.png) no-repeat center;
}
I had to hack up your CSS a bit and simplified some of the selectors to get my head around it, but, give this a try:
http://jsfiddle.net/R56mu/
body {
vertical-align: baseline;
font-weight: inherit;
font-family: inherit;
font-style: inherit;
font-size: 100%;
border: 0 none;
outline: 0;
padding: 0;
margin: 0;
}
#searchbox{
float: right;
overflow:hidden;
}
#search{
width: 200px;
height:32px;
float:left;
padding: 0 0 0 10px;
background-color: #eee;
font-size: 14px;
font-family: 'calibri', Tahoma, Geneva, sans-serif;
border: none;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
}
#submit{
width: 33px;
height:34px;
float:left;
background: url(../images/search_glass01.png) no-repeat center;
border-width: 1px;
border-style: solid;
border-color: #cccccc;
}
#submit:hover{
background: url(../images/search_glass02.png) no-repeat center;
}
input[type="submit"]::-moz-focus-inner {
border: 0;
padding: 0;
}
input[type="text"]::-moz-focus-inner {
border: 0;
padding: 0;
}