I have this problem :
I have a dialog box that I open through JQuery and everithing goes fine, but when I click on it, a thin dotted line appears around the div that contains the dialog box (I have two buttons so this append every time). I would like to remove this line via Jquery or Css, it doesn't matter, I just don't want it to shows.
I think i have to override some css class from dialog box, but I can't figure out wich one.
Thanks.
I guess you can use CSS:
.button-selector {
outline: none;
}
Ok, thanks to your advice I managed what I want.
I've just to set
.ui-widget-content {
outline: none;
}
Related
I got CSS or jQuery/JavaScript question.
I set on many elements tabindex="0" because I need to provide tabbing through page, but I'm wondering why on pages like stackoverflow.com or developer.mozilla.org when I click by mouse I can't see outline on focus, but on my page when I click by mouse I can see outline.
Are they really setting some jQuery/JS preventing showing outline or maybe there is some good way of setting outline in css to prevent showing it?
Edit:
1. Elements on my page should have outline when user is tabbing through page by tab key,
2. Elements on my page should not have outline when user is clicking on elements by mouse
You Can Use
input,button,textarea,-----{
outline: 0; //or outline: none;
} (OR)
// Create One Class With Above Property ,Give That Class To Particular Html Element Like Below ,
.className{
outline: 0; //or outline: none;
}
Does anyone know, is it possible to show outline around input element when user is using sequential navigation (TAB button) and hide outline when user clicks this input element with the mouse? Has anyone implemented this kind of behaviour?
I`m using this property on my :focus selector in CSS file:
:focus {
outline: #00bfff solid 1px !important
}
Currently, outline appears when input element is focused.
BR,
Raimonds
Just blur it on click.
jQuery(document).ready(function() {
jQuery('input').on('click', function() {
jQuery(this).blur();
});
});
This should remove the focus from the input when clicked, thus un-triggering your css rule for :focus, while it will still be applied if your input gets the focus by keyboard navigation.
Edit: Just tried it in Chrome/Windows 7, it doesn't seem to achieve what it is supposed to.
If someone wants to give it a ride to find a working solution, here's a pen:
http://codepen.io/anon/pen/yNMoJv
Here is a fiddle https://jsfiddle.net/hyauyovm/2/
Hope it solves your problem
//HTML
<input>
<input>
<input>
<input>
//JS
<script>
$("input").click(function(){
$(this).addClass('focus');
});
$("input").blur(function(){
$(this).removeClass('focus');
});
</script>
//CSS
input:focus{
outline:2px solid blue;
}
input.focus{
outline:none;
}
you can do this either in js or css for js you have to use blur or in css you can use :focus. Here is an example of both.
using css
using css in fiddle
using js
using js in fiddle
for your case use this
Fiddle
Try this,
input:focus {
outline: #00bfff solid 1px !important
}
When I use .prop('disabled',true) to disable a button, it works, but the button does not look disabled. I remember in the old days when I used .attr('disabled','disabled') to disable buttons, they would become more visibly disabled, i.e. the text would be greyed out or something so the user wouldn't try to click. Now I think the button border fades a bit but the text is not.
What's the easiest way to get the old behavior back? I am lazy and don't want to write one line of code to disable the button and another to make it look disabled - I want to get both effects in a single command if possible. Should I use a different element other than a button? A different method of disabling?
I made a fiddle here: http://jsfiddle.net/ak2MG/. Here's the code.
HTML:
<button type='button' id='mybutton'>Click Me</button>
<div id="mydiv"></div>
Javascript:
$('#mybutton').click( function() {
$('#mydiv').append("<p>Button was clicked.</p>");
$('#mybutton').prop('disabled',true); } );
Or change the opacity of the button
$('#mybutton').click( function() {
$('#mydiv').append("<p>Button was clicked.</p>");
$('#mybutton').prop('disabled',true).css('opacity',0.5);
});
Fiddle
I would add a disabled class to the button.
This lets you control the styling from CSS instead of javascript so all of your styling is in one place (where it should be).
Demo: JSFiddle
HTML
<button type='button' id='mybutton'>Click Me</button>
<div id="mydiv"></div>
JS
$('#mybutton').click( function() {
$('#mydiv').append("<p>Button was clicked.</p>");
$('#mybutton').prop('disabled',true).addClass('disabled');
});
CSS
.disabled {
color: #999;
}
it is pretty simple, just change the text style
$('#mybutton').click( function() {
$('#mydiv').append("<p>Button was clicked.</p>");
my_button_disable(this);
});
function my_button_disable(btn) {
$(btn).prop('disabled',true);
$(btn).css('color', 'lightgray');
// put whatever else you want here
}
http://jsfiddle.net/ak2MG/6/
Simplest - Add a state in CSS
Target it with CSS to change the style,
importantly the pointer-events: none will make it unresponsive. :
button:disabled {
background: #F5F5F5;
color : #C3C3C3;
cursor:none;
pointer-events: none;
}
The change from attr() to prop() was only to the jQuery API and has nothing to do with any difference you are observing in the style of a disabled button.
A disabled button's style is decided by the browser. The fiddle you provided looks very "disabled" in Google Chrome (Version 33.0.1750.154 m). If you'd like to alter the style of a disabled button to your liking, I recommend adding a class OR styling based on attribute
button[disabled],
button.disabled {
color: #999;
background: #DDD;
border: 1px solid #CCC;
}
Actually I'm using a plugin SpryTabs to navigate the menu. I've used two background-images for activating and deactivating of tabs. I'm activating a tab on hover. Means the tab gets highlighted and deactivate the selected tab on clicking other tab.
Until here everything is fine. But the real problem comes when user clicks on the tab after hover, the border gets displayed around the image.
This doesn't happen in Firefox, it happens only in Chrome and IE.
You can add the following code in CSS for specific elements
textarea:focus, input:focus{
outline: none;
}
And for all elements on a page use this generalized code in your css
*:focus {
outline: none;
}
This worked for me when there was an orange coloured border appearing around the images and input boxes.
Try outline: none; on the images
Had same issue once, following style fixed problem:
outline: 1px solid transparent;
Btw outline:none has no effect for chrome for some reason
Useoutline:none or outline:0
Check the similar one here
I am having tough time figure out how to change background color of jQuery UI Dialog.
I've seen many reference how to change/remove title bar but not entire background including those curvy corner.
Here is my try:
http://jsfiddle.net/dEvKb/11/
The problem is .ui-widget-content only applies to square area within the dialog but not including curvy corner.
I found a class .ui-corner-all class hoping it will color the entire background but only half of the dialog is colored. (you can see this in the jsfiddle)
Has anyone done this before?
you can use this way
http://jsfiddle.net/dEvKb/15/
You should set to all class background with use !important.
.ui-dialog,.ui-widget, .ui-widget-content, .ui-corner-all, .foo, .ui-draggable, .ui-resizable {background:yellow !important}
Use the css classes:
ui-dialog
Main container of whole thing
ui-dialog-title
This is where the title actually appears
ui-dialog-titlebar
Area where title of dialog would be if exist
ui-dialog-content
Area where your div is actually loaded
ui-resizable-handle
These divs are used to resize the dialog but are usually invisble according to your setup
ui-dialog-buttonpane
Here is where buttons would go if exist
ui-dialog-buttonset
This is where the buttons actually appear
Also, unlike answer given selected, take note, YOU DON'T HAVE TO USE !important.
If you want a direct call, set everything up and create your dialog. Load the page in Chrome or FF (chrome easier to read). Then simply open the dialog and select the element you want to change. Look at its CSS in your Browser's Developer Tools. You'll be able to see the exact line jqueryui uses to make it's css call. Simply copy that line into your own CSS and ensure it's loaded later and your dialog will get the new overwrite.
If you want to target a specific dialog you can do it this way:
$('#yourDialog').dialog(
{
autoOpen: false,
open: function(e) {
$(e.target).parent().css('background-color','orangered');
}
});
Use this class in css
.ui-dialog .ui-dialog-content {
border: 0;
padding: .5em 1em;
background: #ff0000;
overflow: auto;
zoom: 1;
}
Please be aware that you could also go and make your own custom CSS using this link in jQuery
http://jqueryui.com/themeroller/
jQuery allows us to make a custom-css. Please select the theme you would want from the gallery and hit the edit button, you will be able to change almost everything about the dialog box, as well as the rounded corners.
You then need to download the entire jQuery pack within it you will find css/custom-css folder just put in your css tag and it will be all sorted basically.
The above ways are also true as you will be able to change it but you will have to look for the classes and stuff like that in the CSS well jQuery does that for us in an easy way and it worked for me as well so you can try it too.
What I basically do is create two to three custom style sheets and then load them up and play with them and finally choose one for the website and discard the rest.
I hope this helps...
Short answer
your_stylesheet.css
.ui-widget-content { background: yellow; }
Make sure your stylesheet is included after the JQuery UI stylesheet, e.g.
your_webpage.html
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<link href="your_stylesheet.css" rel="stylesheet" type="text/css"></link>
Long answer
To determine which class and style to override, you will need to inspect a tooltip. Show the tooltip:
$("#selector_for_item_with_tooltip").tooltip('open')
Right-click on the tooltip and choose "inspect". Scroll down in the "Styles" tab until you find the attribute you care about (background-color).
You can click on the value and type in a new value to verify that it will have the effect you desire.
To see the format you will need to use to override the format, click on the filename:line # on the upper-right to go to the .css file that defines the attribute (jquery-ui.css:802)
The format will be
.ui-widget-content
{
background: yellow;
}
Your .css file needs to use the same style and be included after this one (see "short answer", above).
People sometimes incorrectly add !important css suffix to bypass this requirement but that causes all kinds of other headaches.