How do remove the pre-selected Tab indicator from Materializecss? - html

I am using the tab in Materilizecss to design the Navigation tabs in my web app.
By default, the first tab is selected. This is indicated by an underlining line under the first tab, as seen in the picture below.
By default, I do NOT want ANY of the tab to be preselected! To be clear, I do not want any of the tabs to have any underlining by default as seen in the image below.
I want the tabs to be unselected by default until a user chooses one of the tabs, only then will that tab get an underlining line under it.
Unfortunately, I can't seem to find any documentation about removing the default selected tabs/underlining.
Looking forward to your help.

For remove your border bottom :
.target {
border-bottom:none;
}
And to bring up with hover :
.target:hover {
border-bottom: 1px solid red;
}

Related

Elementor dropdown menu highlights menu item and shows border or outline

This is my first question on here. Any feedback is welcome.
I'm creating a dropdown menu for the mobile version of our site and I'm running into an issue that seems quite straight forward.
In this image you see the menu how it should look like when the submenu is extended. When working in the Elementor editor everything looks how it should look. When I go to preview mode or to the live website the following happens when I extend the dropdown menu: lines appear around the extended item what I think are borders or an outline. Also when I close the submenu the menu item gets highlighted: highlighted menu item.
It seems like the menu item is set to active and the default border/overlay is added. I don't see how that is possible since this are my settings: settings. Separation is set to none and the background-color and color are both set to their correct values. Settings for normal and hover are the same as active, since I don't want any changes to happen.
I tried other color values and changed them to transparent. These changes work properly but the black border and overlay remain an issue.
I also tried adding the following CSS to the element but this didn't help:
selector .menu-item {
border: none;
outline: none;
}
I tried rebuilding the menu, some other code snippets, disabling caching plugins, setting separation to solid with 0px and more but nothing fixed it so far. When looking at the elements using inspect I see that when extending the submenu the class changes from elementor-item has-submenu to elementor-item has-submenu highlighted. If I could somehow disable this I think the issue would be solved.
My HTML and CSS knowledge is quite limited so I hope there is an easy fix that I'm not familiar with.
Many thanks in advance!
Edit: Thanks to #Alivia Pramanik for the quick and easy solution!
Welcome to SO. If I am not mistaken, you can change this with Elementor's own design. To do with this custom CSS, add this,
.elementor-nav-menu--dropdown .elementor-item:focus {
background: #0000!important;
outline: 0!important;
}
See the image for your reference

How to fix tabpanel styling problems?

I understand almost nothing in the web, but I had to make a site for myself. I took a ready-made template based on bootstrap 5, on which I managed to implement everything I had conceived, but I cannot get rid of several problems with this:
If you select a tab, then click somewhere outside of all tabs, then when you hover over the active tab, it becomes hovered, which should not be. In general, I tried to repeat a similar component from here.
If you click on the description, then, while holding the mouse, move the cursor a little and release, then there will be two selected tabs.
On click (until you release the mouse), the title color turns light gray. It does not appear in the example from the link, but it is in the finished site. I would be grateful for information on how to fix it.
If you select a tab, then click somewhere outside of all tabs, then when you hover over the active tab, it becomes hovered, which should not be. In general, I tried to repeat a similar component from here.
You need to apply the hover style to the .active tab as well:
.nav-tabs .nav-link.active, .nav-tabs .nav-link.active:hover
{
color: #495057;
background-color: #fff;
border: none;
}
If you click on the description, then, while holding the mouse, move the
cursor a little and release, then there will be two selected tabs.
Get rid of this rule. :focus is causing that behavior. You end up having one .active tab, and another that is :focused, and you have defined the same attributes for both.
/*
.dark .nav-tabs > li > a:focus {
color: #495057;
background-color: #fff;
}
*/
On click (until you release the mouse), the title color turns light gray. It does not appear in the example from the link, but it is in the finished site.
Can't test this one, but possibly also caused by the previously mentioned rule.

keyboard TAB selection is not visible

I have an angular application, when I use keyboard TAB to move around the elements, current focused element is not highlighting.
This is how it looks like when I TAB to an element
This is when I then click on space to expand the accordionTab
I then added the following CSS but it's working only on mouse hover BUT not on tab selection.
::ng-deep {
.ui-accordion-header:hover, .ui-accordion-header:active, .ui-accordion-header:focus {
border: solid #00a1cf 1px !important;
}
}
I had been testing, it is working when I force select focus in chrome developer tools but not when I keyboard tab select.
I am unable to figure out why its not highlighting when focused using keyboard TAB. Can anyone help me out? Thanks in advance :)
What does the markup look like? Normally when tabbing to focus the elements that have focus by default are:
a (anchors)
buttons
inputs
textareas
If you have a different type of element such as a div, you can try and give it focus by adding tabindex to your markup.

Blue highlight when hovering in drop down menu

Is there a way to change the blue highlight color when hovering in a drop down menu? I'm using the drop-down list on my page. I have a drop down menu that allows you to choose the topic.
I would greatly appreciate any help or feedback on this topic.
That blue colour is called an outline, and is used for accessibility reasons.
For example, when you press the tab key to move between form elements, an outline is commonly used so the user knows what element is currently selected.
You can remove this outline with the following CSS:
select:focus {
outline: none;
}
However, It is not recommended to remove this. If you must, you should provide an alternative style by using a background colour, changing the text colour, or provide a custom outline instead of the browser default.
ex:
select:focus {
outline: 2px solid red;
}
.dropdown-item.active, .dropdown-item:active {
background-color: red;
}
These are the Bootstrap classes that need to be overwritten if you wish to change the highlighted background colour when you hover over the dropdown item (i.e. when it is "active").
The classes can be discovered by opening up the Elements section within Google Dev Tools (F12) and then highlighting the element that you wish to restyle. Finding the active states of classes can be a little more tricky and may require a little more digging into the HTML.

Why default button overrides outline on focus event?

I do not know if it is a bug or not, but it seems to be.
When you have a default button and you click it when you have a :focus pseudo class it does not seem to have an outline.
#buttontag:focus {
}
<button id="buttontag" type="button">Focus me</button>
It shows the outline when you use tab key, though.
Nevertheless, it shows the outline both when clicking or using tab key on the button if you change the background-color to it.
#buttontag:focus {
background-color: #dde;
}
<button id="buttontag" type="button">Focus me</button>
But it does not work for all types of background-color. For example, it does not work for background-color: #ddd. In this case it is only shows when you use tab key.
#buttontag:focus {
background-color: #ddd;
}
<button id="buttontag" type="button">Focus me</button>
Here an screenshot when the button is focused, nothing changes.
I know that the background-color: #ddd is the same colour as the default border of the button (both on focus or not focused). I have created the following code to be sure of it.
var buttontag = document.getElementById('buttontag');
buttontag.onfocus = function(){
var border = window.getComputedStyle(buttontag).getPropertyValue("border");
alert(border);
}
var border = window.getComputedStyle(buttontag).getPropertyValue("border");
alert(border);
#buttontag:focus {
background-color: #ddd;
}
<button id="buttontag" type="button">Focus me</button>
I know that rgb(221, 221, 221) is the same as #DDDDDD on hex and that is the same as #ddd. I do not know if it has to be something related about contrast between both colours (there is no contrast because they are the same colour) and outline but it is very strange that in this background-color the outline does not appear.
More and more strange
If you inspect the default button and you force it to be focussed (I am trying on Google Chrome debugger) , it has an outline and shows it on the button. It is the default outline that appears in the rest of buttons with another background-color.
:focus {
outline: -webkit-focus-ring-color auto 5px;
}
And I also wanted to know if it was something related about forcing the button to be in focus state so I created a Javascript snippet to see what outline the button has in focus state.
var buttonFocus = document.getElementById('buttontag');
buttonFocus.onfocus = function(){
var outline = window.getComputedStyle(buttonFocus).getPropertyValue("outline");
alert(outline);
}
#buttontag:focus {
background-color: #ddd;
}
<button id="buttontag" type="button">Focus me</button>
It retrieves the default outline, but does not show it. It seems that it only shows the outline if you force the button to be focussed (on the debugger).
I have searched on the official documentation but could not find anything related about a special behaviour for default buttons or specific background-color.
So here I have some questions:
Why is the outline not displayed on the default button when you click on it?
Why with background: #ddd it is not shown also?
Why is the outline shown when you use tab and not when you click on the button (on the two cases above)?
Why the button has the outline in his CSS but it does not display it? Is it a bug?
Might be wrong.
The default button (in Google Chrome at least) uses appearance
style attribute:
button {
-webkit-appearance: button;
}
The appearance property allows you to make elements look like a
standard user interface element from your operating system. Talking about OS X, standard interface buttons do not have outline
by default.
Very easy way to check how the standard os buttons looks:
alert('I am standard button')
When you've created a button:focus pseudo-class that contained
background or border rule (example #2), you have overridden the
standard appearance by default browser style for button + your
rules.
In example #1, the button:focus is empty, and apparently it is
just ignored by the browser, hence os interface style is applied.
If you will create a style:
button { -webkit-appearance: initial; }
you will get default browser button that has outline.
Chrome's default style for button has a rule:
background-color: buttonface;
Safari and Google Chrome support custom color names that are
references to the currently used colors of user interface elements.
It might be the case, that buttonface is '#dddddd' in your system. Interesting though, as I can see the blue outline in OS X Chrome.
For the questions 3 and 4, I am afraid I cannot replicate it, as I do get outline.
Will update the answer after some research. Cheers! :)
webkit Chrome and Safari behave differently, in that they do not trigger :focus on a click event, but do on tab keyboard event.
That :focus behavior is present, especially on the button element.
So you might have to add tabindex attribute on your button element to let the browser know that this element can receive focus.
tabindex="0"
Since without that tabindex attribute, the browser sees that focus flag as being false, hence no :focus.
See W3C spec:
https://drafts.csswg.org/selectors-3/#the-user-action-pseudo-classes-hover-act
There may be document language or implementation specific limits on which elements can become :active or acquire :focus.
Also see the following regarding focused browsing context
https://html.spec.whatwg.org/multipage/interaction.html#currently-focused-area-of-a-top-level-browsing-context
If the attribute is omitted or parsing the value returns an error.
The user agent should follow platform conventions to determine if the element's tabindex focus flag is set and, if so, whether the element and any focusable areas that have the element as their DOM anchor can be reached using sequential focus navigation, and if so, what their relative position in the sequential focus navigation order is to be.
Modulo platform conventions, it is suggested that for the following elements, the tabindex focus flag be set:
a elements that have an href attribute
link elements that have an href attribute
button elements
You can also see this related StackOverflow question:
css focus not working in safari and chrome
button has a default style define by each browser. it might (and often is) different from browser to browser. But we can overwrite the default values to suit our needs.
Why is the outline not displayed on the default button when you click on it?
The button doesn't enter in focus state when you click. It enters the active state.
Why with background: #ddd it is not shown also?
It does show in my browser, but only when in focus. I your examples you use #ddd and #dde which are 2 very similar grays to the default gray, but once I changed the value I could see the difference.
Why is the outline shown when you use tab and not when you click on the button (on the two cases above)?
The focus state is meant to allow the user to hit the Enter/Return key to activate the button. However, the button doesn't enter the focus state one it is clicked
Why the button has the outline in his CSS but it does not display it? Is it a bug?
It is not a bug. It only displays when in focus state, which can be forced through the code inspector, via javascript or by tabbing through form elements. I used my own example declaring:
outline: 2px solid #ccc;
The focus state is very useful when trying t make the application/website accessible to screen readers for people who are visually impaired. It allows us to add more functions that can be triggered in those situations, and to guide the user through the page when looking at it isn't possible.
The default browser behavior is to show an outline only on focus (by using tab f.e.), not on click. Each browser also may have it's default outline color and width.
To avoid any funny behavior you can overwrite the outline, and also add it to a click:
#buttontag:focus, #buttontag:active {
outline: #ddd solid 2px;
}