IE bug with hover on select and options - css

I'm trying to make a hover on a div but when I hover a option the hover of div is affected.
Example code:
<div class="levelThreeMenuColumnTwo" id="clientFormMenu">
<div class="formMenuPFS">
<select name="select1">
<option value="TN">
Tennessee
</option>
<option value="VA" selected="selected">
Virginia
</option>
<option value="WA">
Washington
</option>
<option value="FL">
Florida
</option>
<option value="CA">
California
</option>
</select>
</div>
</div>
<style>
.formMenuPFS{
display:none;
background-color:red;
width:110px;
height:110px;
position:absolute;
left:200px;
}
.levelThreeMenuColumnTwo:hover .formMenuPFS{
display:block;
}
.levelThreeMenuColumnTwo{
display:block;
background-color:green;
width:200px;
height:200px;
}
</style>
Woking in FF but not in IE.
Correct behaviour:
When hover green div show red div.
When hover select or option keep showing red div.
If javascript is needed I can use dojo 1.4.
Thank you.

I know this is an old problem but I had the same problem I fixed it the following way in your jsbin. Instead of using the CSS :hover I used the jQuery hover and add an event.stopPropagation() too the select.
JS
$(document).ready(function(){
$(".levelThreeMenuColumnTwo").hover(function() {
$('.formMenuPFS').show();
$('.formMenuPFS select').mouseleave(function(event) { event.stopPropagation(); });
}, function() {
$('.formMenuPFS').hide();
$('.formMenuPFS select').mouseleave(function(event) { event.stopPropagation(); });
});
});
jsbin
http://jsbin.com/xitafazoca/

Related

How to change color of Select box after option is selected

I have tried a lot but can not do this. I want to show the red background colour to the selectbox after option is selected.
<select>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<style type="text/css">
select:hover {
background:#Ff0000;
color : #ffffff;
}
</style>
Try this:
var select = document.getElementById('mySelect');
select.onchange = function () {
select.className = 'redText';
}
.redText {
background-color:#F00;
}
<select id="mySelect">
<option>1</option>
<option>2</option>
<option>3</option>
</select>
You need to use javascript/jquery to handle change selection event for selectbox and add red background
HTML
<select>
<option>Select</option>
<option selected>im selected</option>
<option>im not</option>
<option>me too</option>
<option>me either</option>
</select>
CSS
select { color: black; background: red; }
option:not(:checked) { background: white; }
http://jsfiddle.net/kQ6c5/
EDIT
http://www.w3.org/TR/selectors/#checked:
the :checked pseudo-class initially applies to such elements that have the HTML4 selected and checked attributes
Absolutely yes, you can do this using :checked selector,
Check this demo jsFiddle
Syntax
option:checked { }
HTML
<select>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
CSS
option:checked {
background:#Ff0000;
color : #ffffff;
}

how to adjust position of div

i have two divs search and demo. And div demo is
hidden {
display: none
}
and onClick of button
i want to show div demo, whose content is loaded onClick event. Although div demo appears but on right of search div. i want it below search div.
Here is my code:
<div id= search>
<div class="recruitment_input">
<span style="margin-top:6px;">Search<sup> </sup>:</span>
<select id="requesttype" class="select_option">
<option value="none">--Select Search--</option>
<option value="design">Department</option>
<option value="development">First Name</option>
<option value="other">Employee ID</option>
</select>
</div>
</div>
<div id=demo></div>
EXAMPLE HERE
I believe this is what you are trying to accomplish. The $('#requesttype').on('change') method could be replaced with a $('button').on('click') method as well. Please let me know if you have any questions.
Modify with CSS?
<style type="text/css">
div#demo {
position: absolute;`
margin-left:50%;
left:-200px;
width:400px;
height: 400px;
background-color: green;
}
</style>
Hope this what you are looking for:-
HTML
<button id="show">Show</button><br/><br/>
<div id= search>
<div class="recruitment_input">
<span style="margin-top:6px;">Search<sup> </sup>:</span>
<select id="requesttype" class="select_option">
<option value="none">--Select Search--</option>
<option value="design">Department</option>
<option value="development">First Name</option>
<option value="other">Employee ID</option>
</select>
</div></div>
<div class="clear"></div><!--clear class will show your demo div down, even you have used any floating above-->
<div id='demo'>your demo box</div>
CSS
#demo{display: none;}
.clear{clear:both;}
Javascript:
$("#show").click(function(){
document.getElementById("demo").style.display = "block";
});
Here is Fiddle
Add style to your search div.
i.e.
Make <div id='search'>
as <div id='search' style='float:left'>
Then this will place your demo is apper right side of the search div

Dropdown Select Box not showing correctly with custom CSS?

How can I add custom CSS select box styling for Chrome and Safari? IS there a fix?
Answer:
You need to add -webkit-appearance: none; and a height value for Chrome and Safari.
Any Suggestions?
Resource:
http://bavotasan.com/2011/style-select-box-using-only-css/
Try it on JSFiddle Remove and add that style in Google Chrome:
Before:
- http://jsfiddle.net/JoshSalway/jw6Qy/
After:
- http://jsfiddle.net/JoshSalway/cMbTB/
select{
-webkit-appearance: none;
}
<select> tags are stubborn creatures but there is a way.
If there's a "size" parameter in the tag, almost any CSS will apply. Using this technique, I've created a fiddle that's practically equivalent to a normal select tag, plus the value can be edited manually like a ComboBox in visual languages (unless you put readonly in the input tag).
So here's a minimal example to see the principle behind:
(you'll need jQuery for the clicking mechanism):
<style>
/* only these 2 lines are truly required */
.stylish span {position:relative;}
.stylish select {position:absolute;left:0px;display:none}
/* now you can style the hell out of them */
.stylish input { ... }
.stylish select { ... }
.stylish option { ... }
.stylish optgroup { ... }
</style>
...
<div class="stylish">
<label> Choose your superhero: </label>
<span>
<input onclick="$(this).closest('div').find('select').slideToggle(110)">
<br>
<select size=15 onclick="$(this).hide().closest('div').find('input').val($(this).find('option:selected').text());">
<optgroup label="Fantasy"></optgroup>
<option value="gandalf">Gandalf</option>
<option value="harry">Harry Potter</option>
<option value="jon">Jon Snow</option>
<optgroup label="Comics"></optgroup>
<option value="tony">Tony Stark</option>
<option value="steve">Steven Rogers</option>
<option value="natasha">Natasha Romanova</option>
</select>
</span>
</div>
Here's the fiddle with some more styles:
https://jsfiddle.net/dkellner/7ac9us70/
Hope this helps!

jQuery Mobile <select/> style issue

Consider the following code:
<div data-role="fieldcontain">
<label for="name">Car</label>
<select data-inline="true" data-theme="b">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<span>message</span>
</div>
The output as follows:
There is a big gap between the component and the message. How can I reduce this gap to a desired amount?
(I tried applying CSS such as width:100px to the component, but no success)
EDIT :
Here is the live demo: http://jsbin.com/icikif/1
The reason can be found in the CSS of jQm:
#media (min-width: 450px)
.ui-field-contain .ui-select {
width: 78%;
display: inline-block;
}
Add a custom Stylesheet and overwrite the width setting.
I'm not sure what you're asking for, but if you want the "message" to be closer to the styled select, add this rule in your CSS:
.ui-field-contain .ui-select {
width: auto !important;
}
just change auto to the desired amount.

How to do drop-down box like "More action" in gmail

I see the "More Action" drop-down box in gmail inbox page.
It has levels and some disabled item in the list.
How to do that in HTML+CSS?
Thank you
In response to Rob, the reason not to use disabled is IE.
The reason why this is not a good idea is that IE still does not support this in IE6, IE7 or IE8.
http://webbugtrack.blogspot.com/2007/11/bug-293-cant-disable-options-in-ie.html
I'v been searching for something similar and this is my solution. You'll need icons to show/hide, add css and javascript (jquery in this example). It show/hide a menu but could be anything inside .hide div.
css:
.shortasc { background: url("/css/asc.gif") no-repeat 50% 50%;cursor:pointer;}
.shortdesc { background: url("/css/desc.gif") no-repeat 50% 50%;cursor:pointer;}
.hide{ display:none;}
.toggle-menu .title {
text-align:left;
}
.toggle-menu div.more{
position: absolute;
border:#999999 1px solid;
background-color:#FFFFFF;
}
.toggle-menu div.more ul{margin:0; padding:2px; text-align:left;}
.toggle-menu div.more ul li{list-style:none; padding:2px; border:#CCCCCC 1px solid;}
html wich call to a jquery function:
<span class="toggle-menu">
<span class="title" onclick="$(this).win('togglewin');">titulo del menu</span><span class="orden shortasc"> </span>
<div class="more hide">
<ul>
<li>Enlace 1</li>
<li>Enlace 2</li>
<li>and so on</li>
</ul>
</div>
</span>
add method to jquery function or edit to add onClick event in title or create your function, or whatever, this is an example with an jquery function http://docs.jquery.com/Plugins/Authoring#Getting_Started:
(function($) {
var methods={
//... your functions
togglewin:function(){
var p = $(this).position();
var parent = (this).closest('.toggle-menu');
if(parent.find('.more').is(':visible')){
parent.find('.orden').removeClass('shortdesc').addClass('shortasc');
parent.find('.more').slideUp();
}else{
parent.find('.orden').removeClass('shortasc').addClass('shortdesc');
parent.find('.more').slideDown().offset( { top:p.top+12,left:p.left } );
}
return this;
}
};
$.fn.win = function(method) {
if ( methods[method] ) {
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' inexistente en jQuery.win' );
}
}
})(jQuery);
Sorry, I can't upload images, but I like the result.
You can group and disable elements in an HTML <select> element without resorting to the use of JavaScript. Something like the following should work:
<select name="foo">
<optgroup label="Odds">
<option value="1">1</option>
<option value="3">3</option>
<option value="5">5</option>
</optgroup>
<optgroup label="Evens">
<option value="2">2</option>
<option value="4">4</option>
<option value="6" disabled="disabled">6</option>
</optgroup>
</select>
A brief inspection in Firebug shows that Google are faking their drop-down box with a whole bunch of HTML and some clever CSS. Personally, I think taking the "correct" approach and styling it to look prettier is a lot more readable than reinventing the wheel here.
You want an unordered list based popup/drop-down menu.

Resources