I have a form in which one input field is select and it has few option.I am not able to increase the height of the option box and background color.presently it has white colour as given in the picture My html code and css code is below
.select2 {
width: 100%;
overflow: hidden;
font-size: 20px;
padding: 4px 0;
margin: 4px 0;
border-bottom: 2px solid black;
background-color: transparent;
}
.select2 option{
width: 26px;
background-color: none ;
border: none;
background: none;
color: blue;
font-size: 20px;
font-weight:bold;
float: left;
margin: 0 10px;
white-sapce: no-wrap;
text-overflow: ellipsis;
}
.select2 after {
!content: 'Select Role';
font-family: 'material icons';
font-size: 24px;
color: red;
position: absolute;
right: 10px;
top: 10%;
transform: translateY(-50%);
pointer-events: none;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css">
<div class="select2">
<i class="fas fa-user-lock" style="color:black; padding:10px;"> Role</i>
<select >
<option value=""></option>
<option value="user">USER</option>
<option value="rec">Recommending Officer</option>
<option value="store">Store</option>
</select>
</div>
You can use this to increase height:
.select2 select{
height: 50px;
background: transparent;
}
Add more properties here to style the box.
Also correct way to use before and after is :
.select2::after {
....
}
Codepen
Try giving style to select tag, this might works!
select{
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
font-size: 20px;
}
Try this
.select2 {
width: 100%;
overflow: hidden;
font-size: 20px;
padding: 4px 0;
margin: 4px 0;
}
select{
height:30px;
border-bottom: 2px solid black;
background-color: transparent;
}
Related
I have a text in the middle of the div block with a font size 80px. When I hover on the div block, it will change the border size from 1px to 5px with a blue color but the text will moves down.
.calendar-content {
width: 81%;
display: block;
padding: 0;
background: #fff;
float: left;
position: relative;
margin-bottom: 150px;
}
.calendarday-container {
width: 139px;
height: 139px;
float: left;
position: relative;
margin-top: -1px;
margin-left: -1px;
border: 1px solid #ccc;
}
.calendarday-add .calendarday-number {
display: inline-block;
width: 100%;
font-size: 80px;
color: #f1f1f1;
margin: 12px 0px;
text-align: center;
}
.calendarday-number:hover {
margin: 12px 2px;
}
.calendarday-container:hover {
border: 5px solid #2e7ad1;
}
.add-day-ico {
display: none;
width: 21px;
height: 21px;
margin: 22px 0px;
float: right;
}
.calendarday-container:hover .add-day-ico {
display: block;
margin: 22px 0px;
}
<div class="calendarday-container" data-day="0" data-dropable="true">
<a href="/autoresponder/create_day.php?day=0" data-action="click" class="calendarday-add">
<span class="calendarday-number">0</span>
<img src="http://www.clker.com/cliparts/u/F/K/J/M/A/add-button-md.png" sytle="height: 21px; width: 21px;" align="right" style="margin-top: 3px;" class="add-day-ico">
</a>
</div>
Jsfiddle: http://jsfiddle.net/f0k6r9nb/
I have tried to change the margin in the calendarday-container:hover .add-day-ico but it didn't help to resolve the issue.
Can you please show me an example how I can stop the text moving down on hover?
Thank you.
Changing the width of the border from 1px to 5px and recalculating the inner parts is not a practical solution. You could use an additional element, which has 5px of transparent border and change it to 5px of colored border on hover.
Another simple solution would be to use outline instead, as it doesn't add to the elements dimensions:
.calendar-content {
width: 81%;
display: block;
padding: 0;
background: #fff;
float: left;
position: relative;
margin-bottom: 150px;
}
.calendarday-container {
width: 139px;
height: 139px;
float: left;
position: relative;
margin-top: -1px;
margin-left: -1px;
border: 1px solid #ccc;
}
.calendarday-container:hover {
outline: 5px solid #2e7ad1;
}
.calendarday-add .calendarday-number {
display: inline-block;
width: 100%;
font-size: 80px;
color: #f1f1f1;
margin: 12px 0px;
text-align: center;
}
.add-day-ico {
opacity: 0;
width: 21px;
height: 21px;
position: absolute;
bottom: 0;
right: 0;
}
.calendarday-container:hover img {
opacity: 1;
}
<div class="calendarday-container" data-day="0" data-dropable="true">
<a href="/autoresponder/create_day.php?day=0" data-action="click" class="calendarday-add">
<span class="calendarday-number">0</span>
<img src="http://www.clker.com/cliparts/u/F/K/J/M/A/add-button-md.png" class="add-day-ico">
</a>
</div>
A typical approach to showing a border on hover is to have the non-hover state be transparent or a color that matches the background along with the width matching that of the border when hovered.
In this case, there's an existing 1px border. Here, I would change the gray border blue, then use an inset box-shadow to add the additional 4px of the border.
Note: I also removed some margin for .calendarday-number on hover so the number does not shift.
.calendar-content {
width: 81%;
display: block;
padding: 0;
background: #fff;
float: left;
position: relative;
margin-bottom: 150px;
}
.calendarday-container {
width: 139px;
height: 139px;
float: left;
position: relative;
margin-top: -1px;
margin-left: -1px;
border: 1px solid #ccc;
}
.calendarday-add .calendarday-number {
display: inline-block;
width: 100%;
font-size: 80px;
color: #f1f1f1;
margin: 12px 0px;
text-align: center;
}
/*
.calendarday-number:hover {
margin: 12px 2px;
}
*/
.calendarday-container:hover {
border-color: #2e7ad1;
box-shadow: inset 0 0 0 4px #2e7ad1;
}
.add-day-ico {
display: none;
width: 21px;
height: 21px;
margin: 22px 0px;
float: right;
}
.calendarday-container:hover .add-day-ico {
display: block;
margin: 22px 0px;
}
<div class="calendarday-container" data-day="0" data-dropable="true">
<a href="/autoresponder/create_day.php?day=0" data-action="click" class="calendarday-add">
<span class="calendarday-number">0</span>
<img src="http://www.clker.com/cliparts/u/F/K/J/M/A/add-button-md.png" sytle="height: 21px; width: 21px;" align="right" style="margin-top: 3px;" class="add-day-ico">
</a>
</div>
Add this:
.calendarday-container {
border: 5px solid transparent;
outline: 1px solid #ccc;
outline: none;
}
.calendarday-container:hover {
outline: none;
}
Remove this:
.calendarday-number:hover {
margin: 12px 2px;
}
You can use a pseudo element like this. I also removed lot of unnecessary css that was fighting each other
* { margin: 0; padding: 0; box-sizing: border-box; }
body { margin: 5%; }
/* Normal */
.calendarday-container {
width: 150px; height: 150px;
position: relative;
display: flex; align-items: center; justify-content: center;
}
.calendarday-container:after {
content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0;
border: 1px solid #ccc; z-index: -1;
}
.caldndarday-add { text-decoration: none; }
.calendarday-number { font-size: 80px; color: #ccc; }
.add-day-ico { width: 24px; height: 24px; position: absolute; bottom: -8px; right: -8px; }
/* Hover FX */
.calendarday-container:hover:after { border: 10px solid navy; }
.calendarday-container:hover .calendarday-number { color: navy; }
<div class="calendarday-container" data-day="0" data-dropable="true">
<a class="caldndarday-add" href="/autoresponder/create_day.php?day=0" data-action="click">
<span class="calendarday-number">0</span>
<img class="add-day-ico" src="http://www.clker.com/cliparts/u/F/K/J/M/A/add-button-md.png">
</a>
</div>
The text was moving down because, There was increase in border-width from 1px to 5px while hover.
You can either maintain a outline around the box using outline property, and keeping the border: 5px solid transparent to border: 5px solid #2e7ad1 while hovering.
I've created a working fiddle for you, for better understanding: Link to Jsfiddle
I have tried to customized the select drop down. But the arrow of the select is not working. I want to make it as this image. But it is how far I could reach. Here is the image of how I want it to be. Please have a look at it.
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<div class="selectdiv ">
<label>
<select>
<option selected> Select Box </option>
<option>Option 1</option>
<option>Option 2</option>
<option>Last long option</option>
</select>
</label>
</div>
CSS
body {
background: #f2f2f2;
}
.selectdiv {
position: relative;
/*Don't really need this just for demo styling*/
float: left;
min-width: 150px;
margin: 50px 33%;
background:rgba(43, 43, 43, 0.4);
border-radius: 5px 0 0 5px;
padding: 5px;
}
.selectdiv:after {
content: '\f078';
font: normal normal normal 17px/1 FontAwesome;
color: #2B2B2B;
right: -44px;
top: 0px;
height: 33px;
padding: 15px 12px 0px 12px;
border:1px solid #2B2B2B;
border-radius: 0 5px 5px 0;
position: absolute;
}
/* IE11 hide native button (thanks Matt!) */
select::-ms-expand {
display: none;
}
.selectdiv select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
/* Add some styling */
display: block;
width: 100%;
max-width: 150px;
margin: 5px 0px 5px 0px;
padding: 0px 24px;
font-size: 16px;
line-height: 1.75;
color: #333;
background: transparent;
-ms-word-break: normal;
word-break: normal;
border: 0;
border-bottom: 1px solid #fff;
outline:none;
}
I have added the codepen.io link here. Please look at it. https://codepen.io/anon/pen/vzKrXK
modify your .selectdiv:after css like this, change url with any image you want:
.selectdiv:after {
content: '';
background-color: #fff;
background: url(http://icocentre.com/Icons/g-arrow-down.png?size=16) no- repeat right #ddd;
-webkit-appearance: none;
background-position-x: 5px;
width: 10px;
font: normal normal normal 17px/1 FontAwesome;
color: #0ebeff;
right: 11px;
top: 6px;
height: 34px;
padding: 15px 0px 0px 8px;
border-left: 1px solid #0ebeff;
position: absolute;
pointer-events: none;
}
I'm developing drop down list in polymer. Currently I have problem with CSS.
Here you can find example:
jsfiddle example
<div style="width:200px" class="button initial gray">
<div style="padding-left:12px;padding-right:12px;">
<div class="button-value truncated" style="width:inherit;">
Select value very long label with dots at the end
</div>
<div class="arrow">▼</div>
</div>
</div>
I need to create the following drop down list, but I have problem with arrow visible on the right of button.
Question is, how to achieve this:
gif example
I will be very grateful for your help !!!!
You need to use this
text-overflow: ellipsis;
overflow: hidden;
then you will see the three dots after your list item, but also you need to add width for your span
width: 100px
Code example
<div style="width:200px" class="button initial gray">
<div style="padding-left:12px;padding-right:12px;">
<div class="button-value truncated" style="width:158px; display: inline-block">
Select value very long label with dots at the end
</div>
<div style="display: inline-block;margin-top: 12px;vertical-align: top;"class="arrow">▼</div>
</div>
</div>
div.button.orange {
border: 1px solid #FF6200;
background: inherit;
background-color: #FF6200;
border-radius: 5px;
box-shadow: none;
font-family: 'ING Me';
font-weight: 400;
font-style: normal;
font-size: 12px;
color: white;
cursor: pointer;
height: 36px;
box-sizing: border-box;
box-shadow: 1px 1px 5px lightgray;
}
div.button.gray {
border: 1px solid #767676;
background: inherit;
background-color: white;
border-radius: 5px;
box-shadow: none;
font-family: 'ING Me';
font-weight: 400;
font-style: normal;
font-size: 12px;
color: #FF6200;
cursor: pointer;
height: 36px;
box-sizing: border-box;
box-shadow: 1px 1px 5px lightgray;
position:relative;
}
div.button.gray.initial {
color: #767676;
}
div.button.active {
border-radius: 4px 4px 0px 0px;
border: 1px solid #FF6200;
}
div.button-value {
text-align: center;
line-height: 36px;
width: inherit;
}
ul.options>li {
padding-left: 12px;
padding-right: 12px;
line-height: 36px;
}
.truncated {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
ul.options {
color: black;
list-style-image: none;
list-style: none;
list-style-type: none;
border-radius: 0px 0px 4px 4px;
box-sizing: border-box;
position: absolute;
width: auto;
margin: -1px;
padding: 0;
list-style: none;
border: 1px solid #FF6200;
border-top: none;
background-color: white;
box-shadow: 1px 1px 5px lightgray;
}
ul.options>ul {
list-style-type: none;
padding: 0px;
margin: 0px;
}
ul.options>li:hover {
color: white;
background-color: #FF6200;
text-decoration: underline;
}
.arrow{
position:absolute;
right:4px;
top:0;
line-height:36px;
}
<div style="width:200px" class="button initial gray">
<div style="padding-left:12px;padding-right:18px;">
<div class="button-value truncated" style="width:inherit;">
Select value very long label with dots at the end▼
</div>
<div class="arrow">▼</div>
</div>
</div>
I'm trying to make a search -box with categories, like Amazon. The problem is that, when I click inside the text area, the borders change color creating a bad view effect. How can I stop it?
Here is the code:
$border-color: orange;
#form-wrapper {
width: 50%;
height: 40px;
}
.nav-list {
padding: 10px 25px 10px 5px;
position: relative;
float: left;
border: 1px solid $border-color;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
#dropdown {
cursor: pointer;
position: absolute;
height: 100%;
left: 0;
top: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
border: 1px solid $border-color;
}
#dropdown:hover {
background-color: lightgray;
}
.current-selection {
display: inline-block;
font-size: 14px;
}
.in-wrap {
overflow: hidden;
height: 100%;
}
#search-box {
width: 100%;
height: 36px;
border: 1px solid $border-color;
border-left: none;
border-right: none;
line-height: 25px;
font-size: 18px;
padding-left: 100px;
}
.go-button {
float: right;
height: 100%;
background-color: orange;
border: 1px solid $border-color;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
margin: 0;
padding: 0 15px;
}
.go-button:hover {
background-color: rgb(255, 115, 0);
cursor: pointer;
}
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<div id="form-wrapper">
<button class="go-button fa fa-search"></button>
<span class="nav-list">
<span class="current-selection">
</span>
<select id="dropdown">
<option value="books-and-ebooks">Books & eBooks</option>
<option value="audiobooks">Audiobooks</option>
<option value="dvds">DVDs</option>
<option value="other-resources">Other Resources</option>
<option value="random">Random</option>
</select>
</span>
<div class="in-wrap">
<input type="text" name="query" id="search-box">
</div>
</div>
Now I realized that on JSFiddle is not working the same way as on codepen, so here is on codepen: http://codepen.io/1z10/pen/QEbjBx
It was happening because the browsers add outline on input field, to fix this you need to remove on input:focus the attribute outline, declaring this equals none. Like this CSS code:
#search-box:focus{
outline:none;
}
add this to your css:
#search-box:focus {
outline: none;
}
Try this it may help you. I just changed the height...
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<style>
$border-color: orange;
#form-wrapper {
width: 50%;
height: 40px;
}
.nav-list {
padding: 10px 25px 10px 5px;
position: relative;
float: left;
border: 1px solid $border-color;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
#dropdown {
cursor: pointer;
position: absolute;
height: 36px;
left: 0;
top: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
border: 1px solid $border-color;
}
#dropdown:hover {
background-color: lightgray;
}
.current-selection {
display: inline-block;
font-size: 14px;
}
textarea:focus, input:focus{
outline: none;
}
.in-wrap {
overflow: hidden;
height: 100%;
}
#search-box {
width: 100%;
height: 30px;
border: 1px solid $border-color;
border-left: none;
border-right: none;
line-height: 25px;
font-size: 18px;
padding-left: 100px;
}
.go-button {
float: right;
height: 36px;
background-color: orange;
border: 1px solid $border-color;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
margin: 0;
padding: 0 15px;
}
.go-button:hover {
background-color: rgb(255, 115, 0);
cursor: pointer;
}
</style>
<div id="form-wrapper">
<button class="go-button fa fa-search"></button>
<span class="nav-list">
<span class="current-selection">
</span>
<select id="dropdown">
<option value="books-and-ebooks">Books & eBooks</option>
<option value="audiobooks">Audiobooks</option>
<option value="dvds">DVDs</option>
<option value="other-resources">Other Resources</option>
<option value="random">Random</option>
</select>
</span>
<div class="in-wrap">
<input type="text" name="query" id="search-box">
</div>
</div>
Please, don't use outline:none; for disabling the focus outline. You are killing accessibility of the web if you do this. There is a accessible way of doing this.
Check out this article that I've written to explain how to do this correct without breaking you page for a certain segment of your users.
I've created a simple widget in JQuery that wraps texboxes in a div, adds a clear text button and a placeholder. Added the main bits for this at http://jsfiddle.net/BpkDN/, something in the CSS which I can't find is messing the styling up in ie7. Seems to work in every other version.
Here is an extract of what my widget produces:
CSS:
::-ms-clear {
display: none;
}
.jui-textbox {
border: 1px solid #DADADA;
position: relative;
padding:0 !important;
white-space: nowrap;
background: #fff;
overflow: hidden;
height: 33px;
line-height: 33px;
display: inline-block;
*display:inline;
margin: 10px 0;
}
.jui-textbox input {
background-color: transparent;
color: #313131;
height: 33px !important;
line-height:33px\9;
width: 300px;
font-size: 14px;
font-family: 'Open Sans', sans-serif;
padding: 0;
margin: 0 5px !important;
border: none;
float:left;
}
.jui-textbox-placeholder {
position: absolute;
font-size: 14px;
font-family: 'Open Sans', sans-serif;
color: #A1A1A1;
height: 33px;
line-height: 33px;
padding: 0;
margin: 0;
left: 5px;
overflow: hidden;
cursor: text;
}
.jui-textbox-hover {
border: 1px solid #CACACA;
}
.jui-textbox-active {
border: 1px solid #a1a1a1;
}
.jui-textbox-clear.show{
display:inline-block !important;
*display:inline !important;
}
.jui-textbox-clear {
display:none;
cursor: pointer;
background: #fff;
border-left: 1px solid #a1a1a1;
width: 33px;
height: 33px;
background-image:url(icons/x.png);
background-position:center;
background-repeat:no-repeat;
}
.jui-hoverable:hover,.jui-hoverable-hovered
{ background-color: #f1f1f1;}
textarea:focus, input:focus{
outline: none;
}
Html
<div class="jui-textbox">
<div class="jui-textbox-placeholder" unselectable="on" style="font-size: 14px;">
Default
</div>
<input type="text" style="width: 300px;">
<div class="jui-textbox-clear jui-hoverable jui-icons-x"></div>
</div>
Try this:
CSS:
::-ms-clear {
display: none;
}
.jui-textbox {
width: 300px;
border: 1px solid #DADADA;
position: relative;
padding:0 !important;
white-space: nowrap;
background: #fff;
overflow: hidden;
height: 33px;
line-height: 33px;
display: inline-block;
/**display:inline;*/
margin: 10px 0;
}
.jui-textbox input {
background-color: transparent;
color: #313131;
height: 33px !important;
line-height:33px\9;
width: 300px;
font-size: 14px;
font-family: 'Open Sans', sans-serif;
padding: 0;
margin: 0 5px !important;
border: none;
float:left;
}
.jui-textbox-placeholder {
position: absolute;
font-size: 14px;
font-family: 'Open Sans', sans-serif;
color: #A1A1A1;
height: 33px;
line-height: 33px;
padding: 0;
margin: 0;
left: 5px;
overflow: hidden;
cursor: text;
}
.jui-textbox-hover {
border: 1px solid #CACACA;
}
.jui-textbox-active {
border: 1px solid #a1a1a1;
}
.jui-textbox-clear.show{
display:inline-block !important;
*display:inline !important;
}
.jui-textbox-clear {
display:none;
cursor: pointer;
background: #fff;
border-left: 1px solid #a1a1a1;
width: 33px;
height: 33px;
background-image:url(icons/x.png);
background-position:center;
background-repeat:no-repeat;
position: absolute;
right: 0;
}
.jui-hoverable:hover,.jui-hoverable-hovered
{ background-color: #f1f1f1;}
textarea:focus, input:focus{
outline: none;
}
HTML:
<div class="jui-textbox">
<div class="jui-textbox-placeholder" unselectable="on" style="font-size: 14px;">
Default
</div>
<input type="text" style="width: 300px;">
<div class="jui-textbox-clear jui-hoverable jui-icons-x"></div>
</div>
<br/>
<div class="jui-textbox">
<div class="jui-textbox-placeholder" unselectable="on" style="font-size: 14px;">
Focused
</div>
<input type="text" style="width: 266px;">
<div class="jui-textbox-clear jui-hoverable jui-icons-x show"></div>
</div>
Tested in IE7 (Vista).
Demo: http://jsfiddle.net/PENFT/
Another solution, but it's not very clean:
Removing width from .jui-textbox.
Adding float:left; to ".jui-textbox" and changing <br/> with <br
style="clear:both" />.
Note: <br style="clear:both" /> its so dirty.
In this case JavaScript is the simple hack, because in IE7 :focus doesn't work. Take a look at the ie7-js project.
IE7.js is a JavaScript library to make
Microsoft Internet Explorer behave
like a standards-compliant browser. It
fixes many HTML and CSS issues and
makes transparent PNG work correctly
under IE5 and IE6.
Upgrade MSIE5.5-7 to be compatible with MSIE8.
<!--[if lt IE 8]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script>
<![endif]-->
You can also refer to this SO question. IE7 doesn't support this pseudo class.